Forum Moderators: open

Message Too Old, No Replies

Selecting Only Records that Match w/ MySQL.

tricky situation

         

tbarbedo

7:04 pm on Feb 26, 2009 (gmt 0)

10+ Year Member




I have the following select statement...

SELECT dm.dm_id, dm.subject, dm.first_read, dm.sent,
CONCAT(u.firstname, ' ', u.lastname) AS dm_from_name
FROM portal_direct_messages AS dm,
portal_users AS u
WHERE dm.dm_to = '464'
AND dm.dm_from = u.user_id
AND dm.deleted IS NULL

This selects all direct messages for a specific user.

What I want to to do is to check if the field dm.first_read IS NOT NULL meaning the message has been read already...

If it is NOT NULL I would like to only select messages from the past 15 days...

Can someone help me get this done all in one query?

Thanks...

LifeinAsia

7:09 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Sounds like you may want to use what you have then UNION a second SELECT statement with your other requirements.

tbarbedo

8:44 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



thanks for pointing me in the right direction..

looks like its exactly what i needed...thanks again