mercredi 6 mai 2015

Is is possible to have multiple SQL commands within one VALUES entry?

Is is possible to first insert an entry if not exist, and then retrieve the value in one VALUES entry?

Something like this:

INSERT INTO Sections(data) VALUES(
    (INSERT OR IGNORE INTO Courses(column) WHERE column='test'
    SELECT id FROM Courses WHERE column='test')
)

So first I am inserting a value if not exist into Section where the value is referenced from other table. It might not exist, so I want to insert it and then I want to grab that 'id' of new Course entry.

Is is possible?

Aucun commentaire:

Enregistrer un commentaire