Jump to content

HELP :( confused in searching method in mysql


superbogel

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.