- 3

SQL zoo

You manage a zoo. Each animal in the zoo comes from a different country. Here are the tables you have:

19th Jan 2021, 9:54 PM
Himanshu Thakur
Himanshu Thakur - avatar
24 Réponses
+ 20
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
17th Feb 2021, 1:27 PM
Islem M'HALLA
Islem M'HALLA - avatar
+ 3
........is working......... INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
19th Apr 2021, 4:42 PM
Makane Santosh
Makane Santosh - avatar
+ 2
You don't have to quote 1 in VALUES. While writing SELECT name, type country_id, you have to mention table name also, like Animals.name, Animals.type. In the last ORDER BY Countries.country; Hope this is helpful.
19th Jan 2021, 10:08 PM
Divya Yadav
Divya Yadav - avatar
+ 2
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
11th Dec 2021, 7:13 PM
MN FATHIMA RIHAM - s92064451 -321424451
MN FATHIMA RIHAM - s92064451 -321424451 - avatar
+ 2
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc; It`s working
14th Dec 2021, 8:40 AM
Mirmahmud Ilyosov
Mirmahmud Ilyosov - avatar
+ 2
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
26th Dec 2021, 2:36 PM
Nabila Muftia Ma'ruf Kartono
Nabila Muftia Ma'ruf Kartono - avatar
+ 1
Thank you Pallavi It works and I'll work hard to understand every tiny points for this SQL codes
20th Jan 2021, 4:40 PM
Himanshu Thakur
Himanshu Thakur - avatar
+ 1
thanks Islem M'HALLA
17th Feb 2021, 5:41 PM
amerast
amerast - avatar
+ 1
INSERT INTO Animals(name, type,country_id) VALUES('Slim','Giraffe',1); SELECT Animals.name, Animals.type, Countries.country FROM Animals INNER JOIN Countries ON Animals.country_id = Countries.id ORDER BY Countries.country; use this ,it will help you
4th Mar 2021, 4:01 PM
BHUMIKKUMAR KALOLA
+ 1
INSERT INTO Animals(name, type,country_id) VALUES('Slim','Giraffe',1); SELECT Animals.name, Animals.type, Countries.country FROM Animals INNER JOIN Countries ON Animals.country_id = Countries.id ORDER BY Countries.country;
28th Apr 2021, 9:51 AM
Jenelyn Bellen
Jenelyn Bellen - avatar
+ 1
coding zoo please
3rd May 2021, 5:42 PM
Safarudin
Safarudin - avatar
+ 1
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
24th Aug 2021, 8:27 AM
yunus kibebu
yunus kibebu - avatar
+ 1
Working code, that system accepts: /* name - "Slim", type - "Giraffe", country_id - 1 */ INSERT into animals VALUES ('Slim','Giraffe',1); SELECT a.name, a.type, c.country from animals a INNER JOIN Countries c on a.country_id=c.id ORDER by c.country;
26th Apr 2022, 12:33 PM
Ruslan Mustafaev
Ruslan Mustafaev - avatar
0
/* name - "Slim", type - "Giraffe", country_id - 1 */ INSERT INTO animals (name, type, Country_id) VALUES ('Slim', 'Giraffe', '1'); SELECT name type country_id FROM animals INNER JOIN countries ON animal.country_id = countries.country; I'm getting error in "type"
19th Jan 2021, 9:56 PM
Himanshu Thakur
Himanshu Thakur - avatar
0
THANK YOU BHUMIKKUMAR KALOLA
19th Mar 2021, 9:13 PM
Yassin Akhrif
Yassin Akhrif - avatar
0
Select … from
16th Feb 2022, 3:53 PM
Yohannes Stones
Yohannes Stones - avatar
0
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
21st Feb 2022, 3:54 AM
Swati Kumari
Swati Kumari - avatar
0
INSERT INTO Animals(name, type,country_id) VALUES('Slim','Giraffe',1); SELECT Animals.name, Animals.type, Countries.country FROM Animals INNER JOIN Countries ON Animals.country_id = Countries.id ORDER BY Countries.country;
19th Mar 2022, 11:23 PM
Carlos Chachalo
0
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT animals.name, animals.type, countries.country FROM animals, countries WHERE animals.country_id=countries.id order by animals.country_id desc;
21st May 2022, 1:17 PM
Gelbert Millones
0
Hi! you can use one of these options below: NOTE: Check capital letters on values! Option 1: -- name - "Slim", type - "Giraffe", country_id - 1 into table insert into Animals (name, type, country_id) values ('Slim', 'Giraffe',1 ); -- a query to output a new table with each animal's name, type and country fields, sorted by countries. select animals.name, animals.type, countries.country into newtable from animals inner join countries on animals.country_id = countries.id order by countries.country; select* from newtable; Option 2: -- name - "Slim", type - "Giraffe", country_id - 1 into table insert into Animals (name, type, country_id) values ('Slim', 'Giraffe',1 ); -- a query to output a new table with each animal's name, type and country fields, sorted by countries. create table newtable as (select animals.name, animals.type, countries.country from animals inner join countries on animals.country_id = countries.id order by countries.country); select* from newtable;
27th Jun 2022, 4:17 PM
Jihar Mayang
Jihar Mayang - avatar