Hello all!
I am having a slight problem. I want to check how often a certain id number was recorded in one table. Then, using COUNT(), I find the frequency of each number, and order them by frequency, descending.
SELECT `question_id` FROM (
SELECT `question_id`,
COUNT(`question_id`) AS `freq`
FROM `dqa_tags`
GROUP BY `question_id`
) AS `result`
ORDER BY `freq` DESC
LIMIT 0, 30
The above works perfectly for my needs. Now, I want to access another table and retrieve the rows which have ids identical to those returned by the above query. If use this:
SELECT * FROM `dqa_questions`
WHERE `id` = 17
OR `id` = 18
OR `id` = 14
OR `id` = 15
OR `id` = 16
OR `id` = 1
The output is automatically ordered by ascending order. I want MySQL to output it in the order I wrote in the query. How do I do this?