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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.