For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2005 > Re: [PHP-DB] 'OR' logic in mySQL query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] 'OR' logic in mySQL query
Miles Thompson

2005-04-18, 3:56 am

No - OR and AND tests work like this:
(first conditional test) OR (second conditional test)
therefore
((date_received LIKE '$todays_date) OR (date_received LIKE
'$yesterdays_date'))

And of course you will check the MySQL docs to confirm that OR does work in
the WHERE clause, won't you?

Another way of handling the query is to ask for anything less than two days
old, sort of like this:
where date_received >= $today - 2. (And no, that's not accurate syntax.)

Regards - Miles

At 05:04 PM 4/17/2005, Ron Piggott wrote:
>Am I able to use the OR logic in mySQL queries?
>
>$query = "SELECT * FROM table WHERE date_received LIKE '$todays_date' OR
>'$yesterdays_date' ORDER BY prayer_request_reference ASC";
>
>In this above example will the " OR '$yesterdays_date' " work?
>
>In reality I am wanting to preview new entries to the database within the
>past 2 days
>
>Ron
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com