sql - inserting data in two tables Simultaneously -



sql - inserting data in two tables Simultaneously -

i have 2 table in database , position , reservation id of position foreign key in reservation. want insert info in reservation table before , info must inserted position table simultaneously . how can this??? can utilize triggers or store procedure???

i assume tables this:

position: int id reservation: int id, int position_id

first you've got have @ foreign key position_id. if has not null constraint, won't able create reservation entry without before creating position entry.

using "normal" sql queries, it's not possible insert info 2 tables single query.

why need happen within 1 query? because of info integrity? utilize transactions!

sql

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -