Hartley Posted November 3, 2006 Share Posted November 3, 2006 For some reason I'm having trouble with some queries that are longer. I am new to mySQL, so sorry if the question seems rather foolish. There's a table with a lot of numbers in it. For this example, let's just assume there are 3 columns. I want to select all rows that have either the values of 1 or 2 for A, a value of 0 for B, and is greater than 3 for C while sorting by Column C.SELECT * FROM table WHERE B='0' AND C>'3' AND A='1' OR A='2' ORDER BY C DESCThis is logically what I come up with, but it likes to ignore the C>'3' and doesn't always acknowledge the B='0'. REALLY confused. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/26064-longer-queries/ Share on other sites More sharing options...
MCP Posted November 4, 2006 Share Posted November 4, 2006 You're in the MSSQL forum, not the MySQL forum, by the way.I think it's all about parentheses or rather operator precedence. Try:SELECT * FROM table WHERE B='0' AND C>'3' AND (A='1' OR A='2') ORDER BY C DESC Quote Link to comment https://forums.phpfreaks.com/topic/26064-longer-queries/#findComment-119525 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.