Re: php - mysql query issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux