U
U
uuuu2020-07-05 21:49:35
MySQL
uuuu, 2020-07-05 21:49:35

How to display all query values?

It is required to display all the values ​​of this request, but the problem is that id=7 will be displayed only once (instead of three, as in the request).

SELECT name FROM `table1` WHERE id IN(4,5,6,7,7,7);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vapaamies, 2020-07-05
@vapaamies

SELECT 
  a.name
FROM 
  table1 a,
  (
    SELECT 4 id UNION ALL
    SELECT 5 UNION ALL
    SELECT 6 UNION ALL
    SELECT 7 UNION ALL
    SELECT 7 UNION ALL
    SELECT 7
  ) b
WHERE
  a.id = b.id;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question