Querying calender events even if they do not have any for the day

Posted by StealthRT on Stack Overflow See other posts from Stack Overflow or by StealthRT
Published on 2010-05-08T06:32:44Z Indexed on 2010/05/08 6:38 UTC
Read the original article Hit count: 228

Filed under:
|

Hey everyone, i am trying to figure out a way of query my mysql server so that even if a company does not have anything posted for the day the user clicks on their logo, it still adds them to the list.

That sounds a little confusing so let me try to explain it another way.

Say i have 3 company's in my database:

Comp1
Comp2
Comp3

And Comp1 & Comp3 have something for today on the calender but Comp2 does not. I still need it to populate and place that company on the page but have something along the lines of "nothing on the calender for today". The other 2 companys (Comp1 & Comp3) would show the calender posting for that day.

This is the code i have right now:

 SELECT clientinfo.id, clientinfo.theCompName, clientinfo.theURL, clientinfo.picURL,
 clientinfo.idNumber, clientoffers.idNumber, clientoffers.theDateStart, clientoffers.theDateEnd
 FROM clientinfo, clientoffers
 WHERE clientinfo.accountStats = 'OPEN'
 AND clientinfo.idNumber = clientinfo.idNumber
 AND '2010-05-08' BETWEEN clientoffers.theDateStart AND clientoffers.theDateEnd
 GROUP BY clientinfo.idNumber
 ORDER BY clientinfo.theCompName ASC

That executes just fine but for Comp2, it just places the calender info from Comp1 into it when it really doesn't have anything.

The output looks like this:

Comp1 | 2010-05-08 | this is the calender event 1 | etc etc
Comp2 | 2010-05-08 | this is the calender event 1 | etc etc
comp3 | 2010-05-09 | this is the calender event 2 | etc etc

Any help would be great :o)

David

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query