views:

16

answers:

2

Hello,

I have an issue that i'm about to pull my hair out over, ok let me start.

I'm using php and mysql i have a database that holds rows with information and one of the columns has a datetime field in a 24hr format.

I am trying to retrieve information using the following query:

SELECT * FROM `table` 
where `new` != '1' 
AND `time` >= '2010-08-27 22:04:37' 
AND `name` LIKE '%apple%' 
OR `name2` LIKE '%apple%'

My expectations of this query would be to retrieve everything from table where time is greater than or equal to 2010-08-27 22:04:37 . Which I thought would return everything from 2010-08-27 22:04:37 up 2010-08-28 etc. but i'm receiving rows with dates of

2010-08-26 04:59:34
2010-08-26 03:00:00
2010-08-26 23:00:00

Could someone help me please. Thanks in advance!

+1  A: 

Change your query to:

... where new != '1' AND time >= '2010-08-27 22:04:37' AND 
(name LIKE '%apple%' OR name2 LIKE '%apple%')
Anax
THANK YOU VERY MUCH! i was about to pull out my hair over () lol thanks again. gotta remember those OR statements
William Smith
Yes, especially when you issue DELETE queries.
Anax
+1  A: 
SELECT * FROM `table` 
where `new` != '1' 
AND `time` >= '2010-08-27 22:04:37' 
AND  (`name` LIKE '%apple%' 
     OR `name2` LIKE '%apple%')
Michael Pakhantsov
Thanks very much michael you are a life saver.
William Smith