SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE test WITH RECURSIVE cte AS (SELECT 1 id UNION ALL SELECT id+1 FROM cte LIMIT 10) SELECT id FROM cte; CREATE FUNCTION get_rnd_id () RETURNS INT DETERMINISTIC RETURN (SELECT id FROM test ORDER BY RAND() LIMIT 1); WITH RECURSIVE cte AS (SELECT 1 id UNION ALL SELECT id+1 FROM cte LIMIT 10) SELECT id, get_rnd_id() FROM cte; SELECT id FROM test WHERE id = get_rnd_id();

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear