jeudi 21 décembre 2017

MySQL Select last 6 month ago or if result sum less 100 the 100 last inserted rows

I'm looking for a MySql query who returns last 6 months ago update data OR/AND, if the sum of results is less than 100, the next n rows to complete to 100.

The first part of the query is :

SELECT * FROM content, categories 
WHERE categories.id = content.id AND lastUpdate > DATE_SUB(now(), INTERVAL 6 MONTH)
ORDER BY lastUpdate DESC, content.id DESC, content.title ASC

I don't find explanations to do this. Someone could help me ?

Aucun commentaire:

Enregistrer un commentaire