How do I get all rows using IN (), and inside the IN () have duplicate values
SELECT NOME FROM PESSOA WHERE ID IN (1,1,1,2,3,3,4)
I want to return 3 times the name of ID 1, and 2 times the name of ID 3.
How do I get all rows using IN (), and inside the IN () have duplicate values
SELECT NOME FROM PESSOA WHERE ID IN (1,1,1,2,3,3,4)
I want to return 3 times the name of ID 1, and 2 times the name of ID 3.
I found a way, more complex, but I think it's the way
SELECT NOME FROM PESSOA WHERE ID = 1
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 1
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 1
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 2
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 3
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 3
UNION ALL
SELECT NOME FROM PESSOA WHERE ID = 4
I can do a script to generate SQL based on the values of IN
so it will not be very difficult, just work really ...