WHERE condition accross multiple rows

Posted by Chris G on Stack Overflow See other posts from Stack Overflow or by Chris G
Published on 2012-10-30T16:48:18Z Indexed on 2012/10/30 17:00 UTC
Read the original article Hit count: 133

Filed under:
|

I have this table...

--------------------------------------
| user_id |  status   |  status_date |
--------------------------------------
|    1    |  Current  |  2012-08-01  |
|    1    |  Referral |  2012-03-14  |
|    2    |  Referral |  2012-04-23  |
|         |           |              |
--------------------------------------

How would I query to find a distinct user_id who has a referral date before 2012-06-30 AND either a current date of after 2012-06-30 or no current status record at all?

Database is MySQL.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql