owner Posted February 3, 2010 Share Posted February 3, 2010 Is there an AND OR type of statement in mySQL where if you select two fields you can sort them like: WHERE field=1 AND OR field2=1 That way if both fields matched it would be much more specific than just one field matching. Thanks! owner Link to comment https://forums.phpfreaks.com/topic/190790-and-or-statement/ Share on other sites More sharing options...
ahs10 Posted February 3, 2010 Share Posted February 3, 2010 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 More sharing options...
owner Posted February 3, 2010 Author Share Posted February 3, 2010 Well what I am trying to say is if the first where statement is true and finds a specific match, don't do the or statement. If their was not a match then do the or statement. Is that possible? owner Link to comment https://forums.phpfreaks.com/topic/190790-and-or-statement/#findComment-1006435 Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 WHERE CONDITION_A OR ( NOT CONDITION_A AND CONDITION_B ) Link to comment https://forums.phpfreaks.com/topic/190790-and-or-statement/#findComment-1006554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.