SJ_Berwin
asked on
Simple INSERT statement inSQL
I'm trying to use the INSERT statement to insert multiple rows into a already created table using this code but it generates a syntax error. Incorrect syntax near ','.
I thought i would be able to insert multiple rows without having to specify the 'INSERT INTO' statement for every single row.
I've checked already that the values are in the exact order of the column names.
Is this possible?
Code:
INSERT INTO easy_drinks
VALUES
('Blackthorn', 'tonic water', 1.5, 'pineapple juice', 1, 'stir with ice, strain into
cocktail glass with lemon twist'),
('Blue Moon', 'soda', 1.5, 'blueberry juice', 0.75, 'stir with ice, strain
into cocktail glass with lemon twist'),
('Oh My Gosh', 'peach nectar', 1, 'pineapple juice', 1, 'stir with ice, strain
into shot glass'),
('Lime Fizz', 'Sprite', 1.5, 'lime juice', .75, 'stir with ice, strain
into cocktail glass'),
('Kiss on the Lips', 'Cherry Juice', 2, 'apricot nectar', 7, 'serve over ice with straw'),
('Hot Gold', 'Peach nectar', 3, 'orange juice', 6, 'Pour hot orange juice in mug
and add peach nectar'),
('Lone Tree', 'soda', 1.5, 'cherry juice', .75, 'stir with ice, strain
into cocktail glass'),
('Greyhound', 'soda', 1.5, 'grapefruit juice', 5, 'serve over ice, stir well'),
('Indian Summer', 'apple juice' 2, 'hot tea', 6, 'add juice to mug and top off with hot tea'),
('Bull Frog', 'iced tea', 1.5, 'lemonade', 5, 'serve over ice with lime slice'),
('Soda and It', 'soda', 2, 'grape juice', 1, 'shake in cocktail glass, no ice');
I thought i would be able to insert multiple rows without having to specify the 'INSERT INTO' statement for every single row.
I've checked already that the values are in the exact order of the column names.
Is this possible?
Code:
INSERT INTO easy_drinks
VALUES
('Blackthorn', 'tonic water', 1.5, 'pineapple juice', 1, 'stir with ice, strain into
cocktail glass with lemon twist'),
('Blue Moon', 'soda', 1.5, 'blueberry juice', 0.75, 'stir with ice, strain
into cocktail glass with lemon twist'),
('Oh My Gosh', 'peach nectar', 1, 'pineapple juice', 1, 'stir with ice, strain
into shot glass'),
('Lime Fizz', 'Sprite', 1.5, 'lime juice', .75, 'stir with ice, strain
into cocktail glass'),
('Kiss on the Lips', 'Cherry Juice', 2, 'apricot nectar', 7, 'serve over ice with straw'),
('Hot Gold', 'Peach nectar', 3, 'orange juice', 6, 'Pour hot orange juice in mug
and add peach nectar'),
('Lone Tree', 'soda', 1.5, 'cherry juice', .75, 'stir with ice, strain
into cocktail glass'),
('Greyhound', 'soda', 1.5, 'grapefruit juice', 5, 'serve over ice, stir well'),
('Indian Summer', 'apple juice' 2, 'hot tea', 6, 'add juice to mug and top off with hot tea'),
('Bull Frog', 'iced tea', 1.5, 'lemonade', 5, 'serve over ice with lime slice'),
('Soda and It', 'soda', 2, 'grape juice', 1, 'shake in cocktail glass, no ice');
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See the record 'Indian Summer'. You have miss the comma after the 'apple juice'
should be
('Indian Summer', 'apple juice', 2, 'hot tea', 6, 'add juice to mug and top off with hot tea'),
should be
('Indian Summer', 'apple juice', 2, 'hot tea', 6, 'add juice to mug and top off with hot tea'),
i knew sir..... bu mr.author will do the same for 50 point
ASKER
I thought I could save valuable time by having to omit the insert line each time, but thanks to all. !
ASKER
Thanks everyone, Points given to the first replier !
if want to insert the data than do like this
insert into yourdata (
with yourdata as (
select 'Blackthorn' a1, 'tonic water' a2, 1.5 a3, 'pineapple juice' a4, 1 a5, 'stir with ice, strain into cocktail glass with lemon twist' a6 from dual union all
select 'Blue Moon', 'soda', 1.5, 'blueberry juice', 0.75, 'stir with ice, strain into cocktail glass with lemon twist' from dual union all
select 'Oh My Gosh', 'peach nectar', 1, 'pineapple juice', 1, 'stir with ice, straininto shot glass' from dual )
select * from yourdata )