Jump to content

Archived

This topic is now archived and is closed to further replies.

phporcaffeine

MySQL SELECT Query Question

Recommended Posts

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' ?

Share this post


Link to post
Share on other sites
[!--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' ;

Share this post


Link to post
Share on other sites
#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 ;]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[!--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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.