I need to select the rows that do not have the first column matching. For example, from the data below;
Person | Room
---------------------------------------
ben | 1
jake | 3
jake | 1
steven | 2
james | 1
james | 2
james | 3
The query would only return these rows:
Person | Room
---------------------------------------
ben | 1
jake | 3
steven | 2
james | 1
It doesn’t matter what value the room column returns.
And it needs to be able to work with increasing room numbers and different names.
I’ve had no look searching for a answer and can’t figure out how to do it, however it might be my current mindset and it might be really easy to do.
And if you can guarantee that the
ONLY_FULL_GROUP_BYsetting will always be turned off, the following is also possible in MySql:But I’d use the
MIN()function just to be safe…