skip to Main Content

I have a query

SELECT name FROM people WHERE age IN ('34','34')

There is only one row with column age of 34, but I want to return that row 2 times since 34 appears twice in the array.

Any solutions?

2

Answers


  1. You can use union all to make the union of two request.
    In your case it would be :

    SELECT name FROM people WHERE age = '34'
    UNION ALL
    SELECT name FROM people WHERE age = '34'
    
    Login or Signup to reply.
  2. SELECT name FROM people 
    JOIN (
      VALUES ROW('34'), ROW('34')
    ) AS t(age) USING (age);
    

    Or make it a rare usage of NATURAL JOIN:

    SELECT name FROM people 
    NATURAL JOIN (
      VALUES ROW('34'), ROW('34')
    ) AS t(age);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search