Hi I have a dataset where I want to seperate original projects (roots) from copied projects (forked) and insert these two results into a new table.
INSERT INTO root_fork (root_id)
SELECT
projects.id
FROM
projects,
all_projs_limit
WHERE
projects.id = all_projs_limit.project_id
and projects.forked_from is NULL;
and the other is
INSERT INTO root_fork (fork_id)
SELECT
projects.id
FROM
projects,
all_projs_limit
WHERE
projects.id = all_projs_limit.project_id
and projects.forked_from is not NULL;
I want to have both as one SQL statement. Is that possible for example with if and else?
Aucun commentaire:
Enregistrer un commentaire