Variable Visions

Add multiple new tags with an SQL statement

Published Sat. Sep. 22, 2012

Or INSERT multiple entries at once by chaining statements together

INSERT INTO `db_name`.`db_table_name` (`id`, `tag`, `count`) VALUES (NULL, 'AJAX', '0');

 

OR

 

INSERT INTO `db_name`.`db_table_name` (`id`, `tag`, `count`)
VALUES
(NULL, 'AJAX', '0'),
(NULL, 'PHP', '0'),
(NULL, 'jQuery', '0'),
(NULL, 'MySQL', '0')
;

 

SAME BUT CLEANER

INSERT INTO `db_name`.`db_table_name` (`id`, `tag`, `count`)
VALUES (NULL, 'AJAX', '0'), (NULL, 'PHP', '0'), (NULL, 'jQuery', '0'), (NULL, 'MySQL', '0');

 

If you are INSERTING multiple records with many columns, placing returns after each INSERT VALUE helps to visually keep things in order.

 

Keywords:SQL, INSERT, VALUE