Re: [PHP] php - mysql query issue
On Fri, September 15, 2006 7:35 am, 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: > Any ideas why not? I know it's more of a mySQL question so apologies > in > advance! Well, you'd have to tell us what's in $start_string. Otherwise, we are just making wild guesses with nothing to back them up. And, really, to be 100% certain, you'd want to echo out the query you've built after $start_string is interpolated. $query = "SELECT ... '$start_string' ..."; echo $query, "\n"; mysql_query($query, $connection); After you've done that, it's dollars to donuts that you won't need us to answer the question. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php - mysql query issue
Also you should check if dates.date is a DATE type, not DATETIME. Lost some time on that when I wanted to select enregs for a specific date, field was DATETIME and I was querying `date` = '2006-01-01'... :p Andy Dave Goodchild wrote: > On 15/09/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote: >> >> 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... >> >> Yep, I've echoed it and it says: > > "...WHERE dates.date = '2006-10-03'..." > > I think you're right on the join stakes, I will investigate further, many > thanks and have a great weekend. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php - mysql query issue
On 15/09/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote: 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... Yep, I've echoed it and it says: "...WHERE dates.date = '2006-10-03'..." I think you're right on the join stakes, I will investigate further, many thanks and have a great weekend.
Re: [PHP] php - mysql query issue
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
[PHP] php - mysql query issue
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! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk