centenial Posted January 30, 2007 Share Posted January 30, 2007 Hi,I have a MySQL || OR operator question. Here's my query:SELECT id, nameFROM imagesWHERE userid = '1' AND (field1a > 100) || (field1b > 100) AND (field2a > .2) || (field2a > .2)I want to select all records from the image table where userid = '1', where either field1a or field1b are greater than 100, and where field2a or field2b are greater than .2. The query as it is pulls the records for all users from the database, not just the ones for user1. Help anyone? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 30, 2007 Share Posted January 30, 2007 try putting the OR statemenst into more bracketsSELECT id, name FROM images WHERE userid = 1 AND ((field1a >100)||(field1b > 100)) AND ((field2a >.2)||(field2b > .2)) Quote Link to comment Share on other sites More sharing options...
centenial Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks, that works great! Quote Link to comment 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.