close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

mysql query ignoring part of WHERE statement

Thread began 1/20/2015 6:49 pm by david | Last modified 1/21/2015 2:10 pm by david | 268 views | 3 replies

david

mysql query ignoring part of WHERE statement

Hey guys, I've hound myself up against another wall... I have the following select statement ...

"SELECT campain_info.idCampaign, campain_info.couponTitle, campain_info.couponExcerpt, campain_info.couponDetails, campain_info.couponRetailPrice, campain_info.couponPrice, campain_info.amountSavings, campain_info.percentSavings, campain_info.expDate, campain_info.limitedQuantity AS 'Qty', campain_info.image, campain_info.localMarket, campain_info.tags, categories.idCategories, categories.categoryName, categories.categoryIcon, merchants.companyName, merchants.compnayWebsite, order_details.idDetails, Sum( CASE WHEN order_details.idDetails IS NOT NULL THEN 1 ELSE 0 END) AS 'Qty_Sold'
FROM campain_info INNER JOIN categories ON campain_info.categoryId = categories.idCategories INNER JOIN merchants ON campain_info.merchants_idMerchants = merchants.idMerchants LEFT OUTER JOIN order_details ON campain_info.idCampaign = order_details.campain_info_idCampaign
WHERE campain_info.expDate > CURDATE() AND campain_info.localMarket LIKE '$lm' AND campain_info.tags LIKE '$search' AND campain_info.limitedQuantity != 'Qty_Sold'
GROUP BY campain_info.idCampaign"

Everything works perfectly except that the final AND in the WHERE clause doesn't affect the return. For example, one of my campaigns has an available qty of 4, and even though the record set displays 4 has the qnty sold it is still returned in the record set. I've also tried > and <> in place of !=

Can you guys take a look at my select statement and see if I made an error OR if what i'm trying to accomplish can't be done this way?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...