Re: php - mysql query issue

From: Date: Fri, 15 Sep 2006 12:56:16 +0000
Subject: Re: php - mysql query issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241820@lists.php.net to get a copy of this message
Have you tried echoing out your query to run on the backend itself? Maybe there is some problem with how your join is being constructed... Perhaps a left outer join is called for? Hard to tell without having knowledge of your table structure and table data... -B Dave Goodchild wrote:
Hi all. I am building an online events listing and when I run the following query I get the expected result set: SELECT events.id AS eventid, name, postcode, start_time, dates.date FROM events, dates_events, dates WHERE dates_events.event_id = events.id and dates_events.date_id = dates.id AND dates.date >= '$start_string' AND dates.date <= '$end_string' ORDER BY date ASC ...however, when I look for a one-off event the following query fails: SELECT events.id AS eventid, name, postcode, start_time, dates.date FROM events, dates_events, dates WHERE dates_events.event_id = events.id and dates_events.date_id = dates.id AND dates.date = '$start_string' ORDER BY date ASC ...if I query for that date in the dates table using this: SELECT * FROM dates WHERE date = '$start_string' I get the date record I expect. The second query above cannot seem to look for a date that equals the supplied string (BTW, all data has been escaped prior to interpolation in the query string!) Any ideas why not? I know it's more of a mySQL question so apologies in advance!


« previous php.general (#241820) next »