get rows with order in IN clause
Posted: Fri Dec 18, 2015 4:17 pm
Hi There,
I'm struggling to get output in the order as provided:
Correct and desired output
This is the tool order:
Wrong output
How do I get the correct output in IN Clause to have desired output?
I hope my doubt is clear.
I'm struggling to get output in the order as provided:
Code: Select all
select app_value from tool_app where tool_app.id in (select id_tool_app from analysis_link where id_pipeline=13) ORDER BY FIND_IN_SET ( tool_app.id, '3,4,2,1');
+-------------------+
| app_value |
+-------------------+
| RDP v2 |
| Chimera denovo |
| Split library 300 |
| Split library 250 |
+-------------------+
Code: Select all
select id_tool_app from analysis_link where id_pipeline=13;
+-------------+
| id_tool_app |
+-------------+
| 3 |
| 4 |
| 2 |
| 1 |
+-------------+
Code: Select all
select app_value from tool_app where tool_app.id in (select id_tool_app from analysis_link where id_pipeline=13) ORDER BY FIND_IN_SET ( tool_app.id, 'select id_tool_app from analysis_link where id_pipeline=13');
I'm getting the above Wrong output.+-------------------+
| app_value |
+-------------------+
| Split library 250 |
| Split library 300 |
| RDP v2 |
| Chimera denovo |
+-------------------+
How do I get the correct output in IN Clause to have desired output?
I hope my doubt is clear.