[Solved - Operator Error]Is my SQL statement correct?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ridshack
Forum Commoner
Posts: 29
Joined: Wed Oct 11, 2006 10:34 pm

[Solved - Operator Error]Is my SQL statement correct?

Post by ridshack »

Is my SQL statement correct?

When I run this query with any two conditions it works fine but add the third and nothing.

Code: Select all

$rtquery  = "SELECT * FROM Tickets WHERE Queue='$rtclient' AND LastUpdatedBy='$rttech' AND LastUpdated like '$rtdate'";
Thank you for any guidance.
Last edited by ridshack on Wed Nov 15, 2006 9:59 am, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

What is the type of the LastUpdated column? Most probably it's a DATE(TIME) type and thus you probably want to use the = operator instead of the LIKE operator....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

timvw wrote:Most probably it's a DATE(TIME) type and thus you probably want to use the = operator instead of the LIKE operator....
Perhaps if it is DATE or DATETIME then you may have been using LIKE to approximate a date. Use the BETWEEN operator to give a date range ;)
ridshack
Forum Commoner
Posts: 29
Joined: Wed Oct 11, 2006 10:34 pm

Post by ridshack »

It was all me… I was querying other tables to get my variables for this SQL statement and the results where almost correct. This is what happens when a project become more complicated then I am capable of handling late at night. Since Im still in learning mode I thank your responses and will consider how they will affect my query.

Thanks again,
Rid
Post Reply