+ 2
I need help with SQL query to insert a record multiple times at once. Like if I want to insert 'Ani' 100× in a field call 'Name'
SQL
2 Antworten
+ 11
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas.
For example :-
INSERT INTO tbl_name (Name) VALUES ('Ani'), ('Ani'), ('Ani');
0
If it was to add a column with default 'Ani' as value, use ALTER TABLE:
ALTER TABLE table_name
ADD column_name varchar(100)
default 'Ani'
If it was to update rows in a column, use UPDATE
UPDATE table_name
SET column_name='Ani'
Additionally, add WHERE condition to update only selected rows with specific value, otherwise, all records in the column_name will be filled with 'Ani':
WHERE other_column='Sololearner'