SELECT * FROM
(SELECT * FROM (
SELECT users.id, "email", "name", "surname" FROM "users"
INNER JOIN "students" ON ("students"."id" = "users"."verifable_id")
WHERE ( ("verifable_type" = 'ForeignStudent')) ORDER BY "users"."id"
) AS "t1"
UNION
(SELECT * FROM (
SELECT "users"."id", "email", "name", "surname" FROM "users"
INNER JOIN "employees" ON ("employees"."id" = "users"."verifable_id")
WHERE (("users"."id" IN ('1', '2')) AND ("verifable_type" = 'Employee')) ORDER BY "users"."id")
AS "t1")
) AS "t1";
which looks quite complex. Are we missing something?
I'd expect smth like:
SELECT users.id, "email", "name", "surname" FROM "users"
INNER JOIN "students" ON ("students"."id" = "users"."verifable_id")
WHERE ( ("verifable_type" = 'ForeignStudent'))
UNION
SELECT "users"."id", "email", "name", "surname" FROM "users"
INNER JOIN "employees" ON ("employees"."id" = "users"."verifable_id")
WHERE (("users"."id" IN ('1', '2')) AND ("verifable_type" = 'Employee'))
Hi!
I am not sure this is related either to ROM or Sequel, but consider such query:
The corresponding SQL is given as:
which looks quite complex. Are we missing something?
I'd expect smth like: