Elka
05/15/2020, 10:17 AMWITH
clause?
Trying to do something like this:
WITH existingUser AS (SELECT * FROM user WHERE isRemoved = 0);
Elka
05/15/2020, 4:32 PMWITH
would allow me to not repeat myself in other queries. I tried to write this statement
WITH existingUser AS (SELECT * FROM user WHERE isRemoved = 0);
So I can later create a query like this:
selectByName:
SELECT * FROM existingUser WHERE name = ?;
The query selectByName would return me all the users that were not removed and verifying the condition name = ?
alec
05/15/2020, 4:35 PMElka
05/15/2020, 4:38 PMWITH
... This won't work in my case... Is there a way to reuse queries? Otherwise, I will always have to put isRemoved = 0
in all my queries..Elka
05/15/2020, 4:59 PMselectUserWithDepartment
selectUserWithDepartment:
SELECT *
FROM user
INNER JOIN department
ON user.departmentId = department.id;
alec
05/15/2020, 5:51 PMtypealias
for thatalec
05/15/2020, 5:51 PMElka
05/16/2020, 3:46 PM