+ 1

Zoo SQL Project challenge

Hi, I’m having difficulties with the last project. I get wrong result every time when I fix it. Can someone help me with the code or fix it? Thanks! /* name - "Slim", type - "Giraffe", country_id - 1 */ INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); Select name, type, country from animals, countries

17th Dec 2020, 9:23 AM
BatOchir Artur
BatOchir Artur - avatar
20 odpowiedzi
+ 8
Thank you Ipang! I did it! Here’s my solution if you need it! /* name - "Slim", type - "Giraffe", country_id - 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
17th Dec 2020, 10:03 AM
BatOchir Artur
BatOchir Artur - avatar
+ 4
INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); SELECT name, type, country FROM Animals INNER JOIN Countries ON Animals.country_id = Countries.id ORDER BY country
1st Mar 2021, 1:27 AM
Igor Garcia
Igor Garcia - avatar
+ 2
Still showing me an error, for some reason I get the output 3 times
17th Dec 2020, 9:41 AM
BatOchir Artur
BatOchir Artur - avatar
+ 1
You mean output like this? Slim Giraffe 1 Slim Giraffe 1 Slim Giraffe 1 I would guess there are already some records in the table, all with same values. Probably the records entered in previous INSERT command. Oh well, good luck with solution then 👍
17th Dec 2020, 9:45 AM
Ipang
+ 1
No sweat bro 👌 Anyways, now that you mention another table, I guess you may find a need to use JOIN. https://www.sololearn.com/learn/SQL/1865/
17th Dec 2020, 9:52 AM
Ipang
+ 1
No bro this are all shows error at WHERE which is syntax error this is code code. Just replace at" FROM animals, countries" to " FROM Animals INNER JOIN Countries" And remove WHERE end place "ON" there Then all set. INSERT INTO Animals (name,type, country_id) VALUES('Slim', 'Griffe', 1); SELECT Animals.name, Animals.type, Countries, country FROM Animals INNER JOIN Countries ON Animals.country_id=Countries.id ORDER BY Animals.country_id DESC; Which run for sure if not please do same changes Thank you
21st Jan 2021, 12:07 PM
Umesh
Umesh - avatar
+ 1
Hii MD SAIF I DID Try this and it works First Even I made same mistakes by putting "Where" at the place "ON" at which every time shows error at "WHERE" Then I take my time Step back at once check the " JOIN" functions in this, end realised that is wrong at "WHERE" in which syntax of "INNER JOIN"is something else than try one again and it work. If it's right than try,if it's wrong than leave it bro. Thanks you
21st Jan 2021, 12:18 PM
Umesh
Umesh - avatar
+ 1
Working one: /* 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:38 PM
Ruslan Mustafaev
Ruslan Mustafaev - avatar
0
SELECT name, type, country_id FROM animals How is this?
17th Dec 2020, 9:28 AM
Ipang
0
When I do with country_id it works but I need with this format (name, type, country) but country is in another table. When I initialize countries table it and do (name, type, country) it outputs the table 3 times. like Slim Giraffe 1, slim giraffe 2, slim giraffe 3. Thanks for trying anyways bro!
17th Dec 2020, 9:48 AM
BatOchir Artur
BatOchir Artur - avatar
0
So whats the answer?
30th Dec 2020, 4:43 PM
Collins Macharia
Collins Macharia - avatar
0
Ipang, gw outputnya udah sesuai kok masih salah ya
2nd Jan 2021, 11:59 AM
Imam Fauzi
Imam Fauzi - avatar
0
Hello, this is what worked for me: 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 ASC;
28th Jan 2021, 7:43 AM
Nova
Nova - avatar
0
Just Copy and paste the below code, it will complete the use case of zoo SQL problem. _____________________________ insert into animals values ('Slim','Giraffe',1); SELECT initcap(a.name) as name, initcap(a.type) as type, CASE when a.country_id=3 then initcap('India') when a.country_id=2 then initcap('Russia') when a.country_id=1 then upper('USA') END AS country FROM Animals AS a inner join Countries AS c on a.country_id=c.id order by c.country Asc;
3rd May 2021, 9:50 AM
Atul raj
Atul raj - avatar
0
Small hint...worked for me after many failed attempts... make sure to capitalize first letters of Slim and Giraffe...
25th Jul 2021, 1:02 AM
Terry
0
What answer plz tell me
16th Aug 2021, 8:31 AM
Suvarna
Suvarna - avatar
0
All programs comes failure what problem I don't know,,😭😭need answers
21st Sep 2021, 5:28 PM
G. Lokeshwari
0
Same here, I can’t pass this challenge even if the code is as you said
4th Oct 2021, 1:40 PM
Alexandra Linca
Alexandra Linca - avatar
0
INSERT INTO Animals VALUES ('Slim', 'Giraffe', 1); SELECT Animals.name, Animals.type, Countries.country FROM Animals INNER JOIN Countries ON Animals.country_id=Countries.id ORDER BY Animals.country_id DESC; /*Just copy and paste. 100% fix*/
10th Oct 2021, 1:21 PM
Inderjeet Singh
Inderjeet Singh - avatar
0
/* name - "Slim", type - "Giraffe", country_id - 1 */ Insert into Animals values ('Slim', 'giraffe', 1); create view animal_list as ( select Animals.name, Animals.type , countries.country From countries inner join Animals on animals.country_id = countries.id ); select * from animal_list order by country this did not work although it gives same outpout .... can anyone know why ?
24th Feb 2022, 8:42 AM
Kalyan Teja
Kalyan Teja - avatar