superbogel Posted June 1, 2009 Share Posted June 1, 2009 this doesnt work at all ??? SELECT a.`hook`,a.`name`,a.`price_market`,a.`price_store`,a.`pic_small1` FROM `cellphone` AS a LEFT JOIN `cellphone_spec` AS b ON a.`hook` = b.`hook` WHERE 1 AND a.`name` LIKE '%nokia%' AND a.`network` = 'gsm' AND (b.`spec_detail_id` = 69 AND b.`detail` LIKE '%radio%' ) AND (b.`spec_detail_id` = 57 AND b.`detail` != 'No') AND (b.`spec_detail_id` = 18 AND b.`detail` != 'No') AND (b.`spec_detail_id` = 12 AND b.`detail` != 'No') AND (b.`spec_detail_id` = 19 AND b.`detail` != 'No') AND (b.`spec_detail_id` = 20 AND b.`detail` != 'No') GROUP BY a.`hook` but if it only consist this it will work : SELECT a.`hook`,a.`name`,a.`price_market`,a.`price_store`,a.`pic_small1` FROM `cellphone` AS a LEFT JOIN `cellphone_spec` AS b ON a.`hook` = b.`hook` WHERE 1 AND a.`name` LIKE '%nokia%' AND a.`network` = 'gsm' AND (b.`spec_detail_id` = 69 AND b.`detail` LIKE '%radio%' ) GROUP BY a.`hook` i am really newbie in database, pls help somebody many2 thx in advance Quote Link to comment https://forums.phpfreaks.com/topic/160449-help-confused-in-searching-method-in-mysql/ Share on other sites More sharing options...
Ken2k7 Posted June 1, 2009 Share Posted June 1, 2009 Let's talk about logic for a second. If k = 5, can k also equal 7? Can one thing equal to different things simultaneously? Look at your SQL, if b.spec_detail_id = 69, will it also equal 57 or 57 or 18? That's what you're implying when you join them all with ANDs. Also, what do you mean by WHERE 1? Quote Link to comment https://forums.phpfreaks.com/topic/160449-help-confused-in-searching-method-in-mysql/#findComment-847084 Share on other sites More sharing options...
superbogel Posted June 2, 2009 Author Share Posted June 2, 2009 yes i have understand the logic, if i used OR the data will not be accurate, can u please tell me any solutions for this mess really need help urgent thx Quote Link to comment https://forums.phpfreaks.com/topic/160449-help-confused-in-searching-method-in-mysql/#findComment-847557 Share on other sites More sharing options...
fenway Posted June 6, 2009 Share Posted June 6, 2009 No, you don't understand the logic.... do you want to find all instances where there are *all* of those related records? Quote Link to comment https://forums.phpfreaks.com/topic/160449-help-confused-in-searching-method-in-mysql/#findComment-850498 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.