I have a table with the schema below. I need to fetch the last 12 icons that contain images and caricature and ….
I need the last 12 fields that contains images and the last 12 fields that contains caricature. Meaning the last 24 field that contains images or caricature
+------+---------------------+
| id | icons |
+------+---------------------+
| 2583 | images |
| 2582 | images |
| 2581 | images,caricature |
| 2580 | economic |
| 2579 | |
| 2578 | |
| 2577 | |
| 2576 | |
| 2575 | images,audio |
| 2574 | images,infographics |
+------+---------------------+
If you’re looking for 12 items per each of the 3 categories, then only one
limit 12clause clearly won’t solve it. What you’re trying to do is toUNIONthe top 12 results of those 3 categories. So you you should try this:Note: You should not remove the parentheses.
Let me know if you have any doubts.