I need to insert 50 rows into a mysql table. They should all be exactly identical, besides the primary key.
Is there a query that can do this?
I need to insert 50 rows into a mysql table. They should all be exactly identical, besides the primary key.
Is there a query that can do this?
Just use while loop:
declare var1 int
select var1 = 0
BEGIN
WHILE (var1 < 50) DO
insert...
Select var1 = var1 + 1
END WHILE;
END
Brutal but efficient:
INSERT INTO MyTable (data, num)
SELECT 'textdata' as data, 1234 as num
FROM
( SELECT 1
UNION ALL
SELECT 1
) as a,
( SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
) as b,
( SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
UNION ALL
SELECT 1
) as c