TheCandyman
Technical User
I'm trying to write a SQL statement that will look at one column and only show those that have both values. For example, in looking for users that have both 'aaaa' AND 'bbbb' would be User1.
Currently I'm getting all those that have either 'aaaa' or 'bbbb' but not both, and simply switching the OR to a AND results in no results.
Code:
Column1 Column2
User1 aaaa
User2 bbbb
User1 bbbb
User1 cccc
User3 aaaa
Currently I'm getting all those that have either 'aaaa' or 'bbbb' but not both, and simply switching the OR to a AND results in no results.
Code:
SELECT DISTINCT col1
FROM table
WHERE (col2='aaaa' OR col2='bbb');