Jump to content

[SOLVED] WHERE AND/OR Conditionals newbie question


sw9

Recommended Posts

Hi All,

 

I am having a bit of newbie trouble writing a nested mysql statement that has multiple conditions. The issue I'm having is in the WHERE clause. I'm on mysql 5.0.37.

 

Here's what I am trying to do:

 

The first two conditions in my WHERE clause MUST be met, while only 1 of the last three conditions must be met. It is working well except it's not following my TIMESTAMP rule and is instead returning all results regardless of if TIMESTAMP(cp.field_pdate_value) <= NOW().

 

I thought that putting the first two conditions within a set of parantheses was the way to do it, but I'm obviously wrong. Can anyone point me in the right direction?

 

SELECT	NOW(), cp.nid, TIMESTAMP(cp.field_pdate_value), n.title 
FROM content_type_content_program cp 
LEFT JOIN node n ON (n.nid = cp.nid)
LEFT JOIN term_node tn ON (cp.nid = tn.nid) 
JOIN term_data td ON (tn.tid = td.tid)
WHERE (tn.tid = 
(SELECT td.tid FROM term_data td WHERE td.name = 'Burlington' AND td.vid = '31') 
AND TIMESTAMP(cp.field_pdate_value) <= NOW() )
AND td.tid = '312' 
OR td.tid = '221' 
OR td.tid = '222'
ORDER BY cp.field_pdate_value DESC 

 

Thanks much in advance!

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.