AnyhowStep / tsql

A SQL query-builder/ORM
37 stars 3 forks source link

MySQL does not allow `LIMIT` with `IN/ALL/ANY/SOME(query)` #227

Open AnyhowStep opened 4 years ago

AnyhowStep commented 4 years ago

This is invalid in MySQL,

SELECT 1 IN (
  SELECT 1 LIMIT 1
);

It is valid in PostgreSQL and SQLite.

However, MySQL supports,

SELECT 1 IN (
  SELECT (SELECT 1 LIMIT 1)
);
AnyhowStep commented 4 years ago

So, if we have a LIMIT clause, just... wrap it inside another query