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' ? Link to comment https://forums.phpfreaks.com/topic/8554-mysql-select-query-question/ 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' ; Link to comment https://forums.phpfreaks.com/topic/8554-mysql-select-query-question/#findComment-31345 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 ;] Link to comment https://forums.phpfreaks.com/topic/8554-mysql-select-query-question/#findComment-31347 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 Link to comment https://forums.phpfreaks.com/topic/8554-mysql-select-query-question/#findComment-31349 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 Link to comment https://forums.phpfreaks.com/topic/8554-mysql-select-query-question/#findComment-31352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.