I have table with structure like this:
--------------------------------------------
| id | tid | uid | title | time |
--------------------------------------------
| 1 | 3 | 15 | | 120333 |
--------------------------------------------
| 2 | 3 | 15 | Lorem ip..| 120394 |
--------------------------------------------
| 3 | 3 | 15 | | 120344 |
--------------------------------------------
| 4 | 2 | 15 | Lorem ip..| 128994 |
--------------------------------------------
| 5 | 2 | 15 | Lorem ip..| 126782 |
--------------------------------------------
And i have query like this (it selects all records with “uid” – user id that is 15):
SELECT * FROM my_table WHERE uid = :uid GROUP BY tid ORDER BY time DESC
Thos works fine, BUT u have one problem: “title” row is often empty when i display results of this query. (note: for every “tid” number there must be at least one “title”)
How can i force this query to always display title, so it is never empty?
IF you want to take an arbitrary value for the Title field, or if they are all the same, you could do a MIN() on that column. MIN will omit nulls.