More cars question: INSERT INTO multiple rows | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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

2nd Mar 2021, 7:23 AM
Anis Ali Khan
10 Respostas
+ 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.
2nd Jun 2021, 7:13 PM
Dave Wiener
Dave Wiener - avatar
+ 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;
11th Apr 2021, 5:31 PM
Allan Stocco Rezende
Allan Stocco Rezende - avatar
+ 1
You have to add: ; SELECT * FROM garage ; at the end in order to show the results
27th Apr 2021, 9:35 PM
Victor Vogt
Victor Vogt - avatar
+ 1
insert into Garage values (6,'Mercedes-Benz','G 63',2020) 7, 'Porsche', 'Panamera', 2020) Select * from Garage;
5th Jan 2022, 5:09 AM
JAMESHA IBRAHIM K
JAMESHA IBRAHIM K - avatar
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.
2nd Mar 2021, 10:35 AM
Ore
Ore - avatar
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.
3rd Mar 2021, 12:53 PM
Anis Ali Khan
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;
30th May 2021, 5:48 AM
Hamid Karimi
Hamid Karimi - avatar
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.
16th Jan 2022, 11:11 PM
Nick Kilvert
0
This works insert into Garage values (6,'Mercedes-Benz','G 63',2020), (7, 'Porsche','Panamera', 2020); Select * from Garage
8th Feb 2023, 12:37 PM
Meghana
Meghana - avatar
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
9th Sep 2023, 4:49 AM
Killer Frost
Killer Frost - avatar