Jump to content

AND OR statement


owner

Recommended Posts

i'll try to help, just cuz i'm hanging out seeing if anyone will initially bite on my question.  i think the best help i can give you is to tell you that it is unclear what you are asking in your post.  you need to rephrase your question and providing an example query (the full query, not just the where clause) would prolly help too.  finally, although you question isn't affected by version so much... they are really anal about that here, so post your mysql server version too.  when in rome......

 

now "AND" and "OR" are both operators in sql.  you would use "AND" to match more than one statement and you would use "OR" to match just one statement.  so an attempt at helping you out, pay attention to the brackets... it's structured query language, it should make sense....

 

SELECT * FROM `database`.`table` WHERE (`field` = 1 AND `field2` = 1) OR (`field` = 2 AND `field2` = 2)

 

this would match rows where field and field2 both equal 1

it would also match rows where field and field2 both equal 2

Link to comment
https://forums.phpfreaks.com/topic/190790-and-or-statement/#findComment-1006143
Share on other sites

Archived

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

×
×
  • Create New...

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.