EXAMPLE:
CREATE TABLE t (A INT);
INSERT INTO t VALUES(1),(2),(3),(4),(5);
This works:
SELECT A FROM t WHERE A=(SELECT 1)
This does not:
SELECT A FROM t LIMIT (SELECT 1);
This works:
SELECT A FROM t WHERE A=substring((SELECT 123),1,1);
This does not:
SELECT A FROM t WHERE A=1 PROCEDURE ANALYSE((SELECT 1),10000);
What makes some clauses and functions support SELECT statements and others not support it. I would think that running (SELECT 1)
returns a 1
as a parameter and as long as the parameter is the expected type it should work. This seems to be true in some cases, but not others. Why is that?
Best Answer
this is the way LIMIT can be done in MySQL using variable parameters:
In the place where it says
SET @skip=1
, One can also writeSET @skip=(SELECT 1)
.