• + 0 comments

    WITH RECURSIVE numbers AS( SELECT 2 AS num UNION ALL SELECT num + 1 FROM numbers WHERE num < 1000 ), Prime AS ( SELECT num FROM numbers n WHERE NOT EXISTS( SELECT 1 FROM numbers n1 WHERE n.num % d.n1.num = 0 AND n.num != n1.num ) )

    SELECT GROUP_CONCAT(num SEPARATOR '&') AS pnumbers FROM Prime;