0
More cars question: INSERT INTO multiple rows
Hello, Why is SQL unable to understand my query? 1. Same # & order of columns 2. No null values 3. Comma separated rows in parentheses after a single VALUES statement as per SQL â08-â12 syntax. 4. Semicolon at the end /* My query: INSERT INTO Garage VALUES (6, 'Mercedes-Benz', 'G 63', 2020), (7, 'Porsche', 'Panamera', 2020); */ What more do you want from me, SQL? Iâm human. We created you. And yet you dare show such defiance towards your masters? *sound of sword being unsheathed* This for is proving to be reluctant to be slain. SQL samurais. I implore that ye come to my aid on the battlefield. Such an impudent for must not be allowed to escape. Yours, Khan
11 Answers
+ 11
Insert into Garage
values
(6, 'Mercedes-Benz', 'G 63', 2020),
(7, 'Porsche', 'Panamera', 2020);
Select * from Garage;
Note the ; after ...2020); Select...
This let me have the right output.
+ 3
INSERT INTO Garage (id, make, model, prodyear)
VALUES (6, 'Mercedes-Benz', 'G 63', 2020);
INSERT INTO Garage (id, make, model, prodyear)
VALUES (7, 'Porsche', 'Panamera', 2020);
SELECT * FROM Garage;
+ 1
You have to add: ; SELECT * FROM garage ; at the end in order to show the results
+ 1
insert into Garage values
(6,'Mercedes-Benz','G 63',2020)
7, 'Porsche', 'Panamera', 2020)
Select * from Garage;
0
You are missing the column names.
INSERT INTO Garage (`id`, `name`, `model`, `year`)
VALUES (6, 'Mercedes-Benz', 'G 63', 2020),
(7, 'Porsche', 'Panamera', 2020);
Replace id, name, model, year with the right names.
0
I tried that. itâs still giving me a no output error.
I donât think you need to specify column names here, because the rows weâre inserting have the same columns in the same order. Maybe theres an error in the app, its not handling SQL code properly.
0
this code is Ok. ;)
/*
6, 'Mercedes-Benz', 'G 63', 2020
7, 'Porsche', 'Panamera', 2020
*/
INSERT INTO Garage
VALUES
(6, 'Mercedes-Benz', 'G 63', 2020),
(7, 'Porsche', 'Panamera', 2020);
select * from Garage;
0
It worked for me when I added "select*from Garage;" after the statement. Which is weird, because this aspect of the query was not mentioned in the "insert into" lesson.
0
This works
insert into Garage values
(6,'Mercedes-Benz','G 63',2020),
(7, 'Porsche','Panamera', 2020);
Select * from Garage
0
You might want to try explicitly specifying the columns in your INSERT INTO statement to ensure the order matches the data you're providing. For example:
INSERT INTO Garage (ID, Make, Model, Year)
VALUES
(6, 'Mercedes-Benz', 'G 63', 2020),
(7, 'Porsche', 'Panamera', 2020);
You can get more ideas and reviews about cars at https://truecarexpert.com
0
INSERT INTO Garage
VALUES
(6, 'Mercedes-Benz', 'G 63', 2020),
(7, 'Porsche', 'Panamera', 2020);
select * from Garage;