Search
 
SCRIPT & CODE EXAMPLE
 

SQL

insert many to many sql

INSERT INTO persons (firstname,lastname) VALUES ('John','Doe');
SET @person_id = LAST_INSERT_ID();

INSERT IGNORE INTO properties (property) VALUES ('property_A');
SET @property_id = LAST_INSERT_ID();
INSERT INTO has_property (person_id,property_id) VALUES(@person_id, @property_id);

INSERT IGNORE INTO properties (property) VALUES ('property_B');
SET @property_id = LAST_INSERT_ID();
INSERT INTO has_property (person_id,property_id) VALUES(@person_id, @property_id);

INSERT IGNORE INTO properties (property) VALUES ('property_C');
SET @property_id = LAST_INSERT_ID();
INSERT INTO has_property (person_id,property_id) VALUES(@person_id, @property_id);
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql into outfile with headers 
Sql :: mysql where in maintain order group_concat 
Sql :: mysql keyword search 
Sql :: sql vs nosql or mysql vs mongodb 
Sql :: datagrip execute procedure 
Sql :: Mysql Selected All Duplicate Rows 
Sql :: php insert null mysql 
Sql :: An error occurred while installing mysql (2.9.1), and Bundler cannot continue 
Sql :: foreign key on table oracle 
Sql :: sql server datetime 
Sql :: how to comment in sql 
Sql :: to show sp in sql server 
Sql :: order by sql query 
Sql :: sqlalchemy get ids 
Sql :: sql distinct vs unique 
Sql :: python connect microsoft sql server 
Sql :: sql exemplos 
Sql :: how to select multiple columns from different tables in mysql 
Sql :: mysql sql.gz 
Sql :: first mysql 
Sql :: find the all the constraints in a specific table 
Sql :: how to check which table has data in mysql 
Sql :: mysql grouping functions 
Sql :: windows aggregate functions in postgresql 
Sql :: show sql property syntax for jpa. 
Sql :: mysql copy table rows from one database to another 
Sql :: Write the order of execution of all the SQL clauses and statements 
Sql :: 0 
Sql :: date on sql 
Sql :: drop procedure postgres 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =