sniperscope Posted April 17, 2012 Share Posted April 17, 2012 Hello I wonder why my query return value. It should be return 0 but it gives me 1 record with every value is null. Here is my query $today = mktime(0, 0, 0, date("n"), date("d"), date("Y")); SELECT s.register_date, s.shop_name, s.id, s.shop_type, s.shop_area, s.deli_area, s.shop_hour, s.shop_phone, g.staff_id, g.staffl_name, g.staff_recommend, c.course_course, n.news_icon, COUNT( n.news_id ) AS NewsNumber, COUNT( cp.coupon_id ) AS CouponNumber, COUNT( g.staff_id ) AS StaffNumber, COUNT( w.shukin_id ) AS ShukkinNumber FROM shop_master s LEFT JOIN course c ON s.id = c.shop_id LEFT JOIN staff_master g ON s.id = g.shop_id LEFT JOIN news_event n ON s.id = n.shop_id LEFT JOIN coupon cp ON s.id = cp.shop_id LEFT JOIN ( SELECT w.shop_id, w.shukin_id FROM shukkin_master w WHERE staff_date = '1334588400' GROUP BY staff_master_id )w ON s.id = w.shop_id WHERE s.shop_area LIKE '%osaka%' AND s.shop_type <> 'pizza' ORDER BY g.staff_recommend DESC , n.news_date DESC , s.register_date DESC This query MUST give me 0 record since there is no pizza shop. I really appreciate for any help. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 17, 2012 Share Posted April 17, 2012 but your query is looking for every shop type that isn't pizza : AND s.shop_type <> 'pizza' Quote Link to comment Share on other sites More sharing options...
sniperscope Posted April 17, 2012 Author Share Posted April 17, 2012 Dear Muddy_Funster Yes you are right so far i know to get non-include data by using <> How can i get 0 record? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 17, 2012 Share Posted April 17, 2012 change it to = pizza you see: This query MUST give me 0 record since there is no pizza shop. but your query is looking for every shop type that isn't pizza : AND s.shop_type <> 'pizza' it's not checking what you think it is, even though you know it's not. Quote Link to comment Share on other sites More sharing options...
sniperscope Posted April 17, 2012 Author Share Posted April 17, 2012 Dear Muddy_Funster Seems i didn't make my self clear. I don't want to get pizza shops. I want to get NON-pizza shops Shops may be flower shop, or restaurant, or night club but not pizza. Pizza is just an example. Simply user will select some shop from shop category dropdown menu and i want to list every thing besides what he selected. Quote Link to comment Share on other sites More sharing options...
fenway Posted April 21, 2012 Share Posted April 21, 2012 You need an "=" and a LEFT JOIN.. IS NULL. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.