Search code examples
mysqlsqlselectwhere-clause

MySQL - WHERE IN() - get all data


I am having this query: SELECT * FROM data WHERE ID IN(1,2,3);

I would like to know if there is any possibility to change an IN argument value to get all rows in the table. Something like:

SELECT * FROM data WHERE ID IN(LIKE %%);
SELECT * FROM data WHERE ID IN(ANY);
SELECT * FROM data WHERE ID IN(ALL);
etc.

I know that all I have to do is just remove "WHERE ID IN(..)" to get what I need but this is more theoretical question.


Solution

  • I think about next approach:

    SELECT * FROM data WHERE ID IN(SELECT ID FROM data);
    

    It's stuppid, but answer the question :)