I'm new to SQL and I'm working on something to sort a table according to values in a second table so I have something like this
SELECT id FROM (SELECT id, COUNT(*) FROM secondTable GROUP BY id ORDER BY COUNT(*) DESC) AS ordering;
and it's getting a column from the second table and orders it. Now I have a column like 7, 3, 8, 10, 4, 6 and I would like to sort another table based on those values so 7 would be ranked the highest. I looked into options and it seemed like something like this
SELECT * FROM firstTable ORDER BY FIELD(id, ordering);
would do what I want but I need to pass the column as individual arguments to FIELD(). Is there a way I can do it this way or some other way?