phporcaffeine Posted April 27, 2006 Share Posted April 27, 2006 What's the 'proper' syntax for multiple WHERE conditions?1.) SELECT * FROM table WHERE col_1 = 'val_1' AND col_2 = 'val_2' ?2.) SELECT * FROM table WHERE col=1 = 'val_1', col_2='val_2' ? Quote Link to comment Share on other sites More sharing options...
onepixel Posted April 27, 2006 Share Posted April 27, 2006 [!--quoteo(post=369245:date=Apr 27 2006, 09:40 AM:name=phpORcaffine)--][div class=\'quotetop\']QUOTE(phpORcaffine @ Apr 27 2006, 09:40 AM) [snapback]369245[/snapback][/div][div class=\'quotemain\'][!--quotec--]What's the 'proper' syntax for multiple WHERE conditions?1.) SELECT * FROM table WHERE col_1 = 'val_1' AND col_2 = 'val_2' ?2.) SELECT * FROM table WHERE col=1 = 'val_1', col_2='val_2' ?[/quote]The first expression is the right one:SELECT * FROM table WHERE col_1 = 'val_1' AND col_2 = 'val_2' ; Quote Link to comment Share on other sites More sharing options...
bbaker Posted April 27, 2006 Share Posted April 27, 2006 #1 (if the query must satisfy [i]BOTH[/i] WHERE conditions, replace AND with OR if it can meet one or the other.)guess you already got it ;] Quote Link to comment Share on other sites More sharing options...
phporcaffeine Posted April 27, 2006 Author Share Posted April 27, 2006 Yeah, I got it ....I was going nuts I couldn't get why my query was bombing? Then I noticed I had 'AND' in the query as 'ADN'BIG DIFFERENCE when you can spell, LMAO Quote Link to comment Share on other sites More sharing options...
emehrkay Posted April 27, 2006 Share Posted April 27, 2006 [!--quoteo(post=369254:date=Apr 27 2006, 11:08 AM:name=phpORcaffine)--][div class=\'quotetop\']QUOTE(phpORcaffine @ Apr 27 2006, 11:08 AM) [snapback]369254[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yeah, I got it ....I was going nuts I couldn't get why my query was bombing? Then I noticed I had 'AND' in the query as 'ADN'BIG DIFFERENCE when you can spell, LMAO[/quote]maybe its the lack of caffine Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.