Having Trouble With MYSQL String

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
snowrhythm
Forum Commoner
Posts: 75
Joined: Thu May 04, 2006 1:14 pm
Location: North Bay Area, CA

Having Trouble With MYSQL String

Post by snowrhythm »

This is probably a simple problem, but I need a quick solution and I can't find it anywhere so far. The string below doesn't work:

Code: Select all

$sqlString =  "SELECT DATA1, DATA2, DATA3 FROM TABLE WHERE DATA1 LIKE "%x%" AND WHERE DATA2 LIKE "%y%" AND WHERE DATA3 LIKE "%z%" ORDER BY DATA1 ASC";
anyone know what's wrong with my syntax? Thanks for any help.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Re: Having Trouble With MYSQL String

Post by AKA Panama Jack »

snowrhythm wrote:This is probably a simple problem, but I need a quick solution and I can't find it anywhere so far. The string below doesn't work:

Code: Select all

$sqlString =  "SELECT DATA1, DATA2, DATA3 FROM TABLE WHERE DATA1 LIKE "%x%" AND WHERE DATA2 LIKE "%y%" AND WHERE DATA3 LIKE "%z%" ORDER BY DATA1 ASC";
anyone know what's wrong with my syntax? Thanks for any help.
Change it to...

Code: Select all

$sqlString =  "SELECT DATA1, DATA2, DATA3 FROM TABLE WHERE DATA1 LIKE "%x%" AND DATA2 LIKE "%y%" AND DATA3 LIKE "%z%" ORDER BY DATA1 ASC";
You only need one WHERE argument.
User avatar
snowrhythm
Forum Commoner
Posts: 75
Joined: Thu May 04, 2006 1:14 pm
Location: North Bay Area, CA

Post by snowrhythm »

aha, thanks much mr. jack.
Post Reply