Here is the example data set i have :
id | messageread | timestamp
1 | 'yes' | 999
1 | 'yes' | 0
1 | 'no' | 0
I’m doing so :
SELECT *
FROM nvm
GROUP BY id
You will note that the data set is already ORDER BY timestamp DESC
As it should, MySQL is returning the first row.
What i’d want is MySQL to return the first row, but with messageread='no' IF messageread='no' in one of the grouped rows, no matter if the normally returned row is 'yes' or 'no'
Is that possible with MySQL? I promised myself to do as much as possible with MySQL and not PHP 🙂 Thanks!
In order to make sure all rows are from the same column do:
This will select the minimum or maximum row from table1. And all columns will be from the same row.
If it doesn’t work you need to change the
<to a>it’s late here and I cannot test the query, but it should do the job.Warning, antipattern ahead
This has the smell of rotten eggs all over it, but if you want to mix and match fast do: