Skip to content
Advertisement

SQL Multiple data input at the same time

there are 2 different queries below. How can I run them at the same time? I mean, these 2 data’s will be into on the same row. For example: https://prnt.sc/rtkytf

INSERT INTO data (request_string)
VALUES 
('request_string_test1'),
('request_string_test2');

INSERT INTO data (redirect_string)
VALUES 
('redirect_string_test1'),
('redirect_string_test2');

Advertisement

Answer

Doesn’t this do what you want?

INSERT INTO data (request_string, redirect_string)
    VALUES ('request_string_test1', 'redirect_string_test1'),
           ('request_string_test2', 'redirect_string_test2');

Otherwise, if you really want to insert four rows:

INSERT INTO data (request_string, redirect_string)
    VALUES ('request_string_test1', DEFAULT),
           ('request_string_test2', DEFAULT),
           (DEFAULT, 'redirect_string_test1'),
           (DEFAULT, 'redirect_string_test2');

The default value is often NULL (because no DEFAULT is specified). If you know that is the case, you can use NULL instead.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement