I want to write a SQL query where if the datetime is not been assigned I want to replace a string which can select all date and time.
How Actually it works:
SELECT * FROM `entry` WHERE `user` like 'TOM' or `user` like 'PHP'
and `entry_datetime` between '2013-03-13 22:20:18' and '2013-03-13 22:20:26'
My Doubt: If the php do not get the value of the date from and to but I don't want to change the query by deleting the AND condition but I want to replace some thing in between date and time and still the query should run:
SELECT * FROM `entry` WHERE `user` like 'TOM' or `user` like 'PHP' and
`entry_datetime` between ' ' and ' '
I tried the following but its not working? can we write a query like this?
SELECT * FROM `entry` WHERE `user` like 'TOM' or `user` like 'PHP' and
`entry_datetime` between '%%' and '%%'
I just tries the above like because we use it in LIKE command so I tried that? Any advice will be much helpful.
I dont know the way I am trying is right or wrong but I can't change the Query id the date value is not assigned.