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? Link to comment https://forums.phpfreaks.com/topic/36380-solved-mysql-operator/ 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)) Link to comment https://forums.phpfreaks.com/topic/36380-solved-mysql-operator/#findComment-173030 Share on other sites More sharing options...
centenial Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks, that works great! Link to comment https://forums.phpfreaks.com/topic/36380-solved-mysql-operator/#findComment-173033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.