0

Need help with the sql zoo module

I’m confused with how form the statement. Do I try to insert the new data first and then join? Or should I create a view ? But then where do I place the insert statement ?

6th Apr 2021, 5:51 PM
Chris Frausto
Chris Frausto - avatar
14 Respostas
+ 1
Thank you so much for your help!
6th Apr 2021, 6:51 PM
Chris Frausto
Chris Frausto - avatar
+ 1
This is where im at
6th Apr 2021, 6:52 PM
Chris Frausto
Chris Frausto - avatar
+ 1
insert into animals (name,type, country) values('Slim','Giraffe', 1) select animals.name, animals.type, animals.country_id, countries.id, countries.country from animals inner join countries on animals.country_id = countries.id ;
6th Apr 2021, 6:52 PM
Chris Frausto
Chris Frausto - avatar
+ 1
I am missi f the order by?
6th Apr 2021, 6:53 PM
Chris Frausto
Chris Frausto - avatar
+ 1
I fixed the select statemnt which gave me the right output minus the giraffe select animals.name, animals.type, countries.country from animals inner join countries on animals.country_id = countries.id order by countries.country ;
6th Apr 2021, 7:00 PM
Chris Frausto
Chris Frausto - avatar
+ 1
When i added the insert to statement i got an error again
6th Apr 2021, 7:00 PM
Chris Frausto
Chris Frausto - avatar
0
First insert the giraffe with a insert into statement. Then do the join statement. Just sql, no view select from inner join orderby. Just 2 sql statements. First is the insert, second is the join.
6th Apr 2021, 6:22 PM
sneeze
sneeze - avatar
0
Its still showing as wrong says there is a problem with the select statement
6th Apr 2021, 6:52 PM
Chris Frausto
Chris Frausto - avatar
0
Yes. In the problem description it says. Sorted by countries That is an order by
6th Apr 2021, 6:59 PM
sneeze
sneeze - avatar
0
end the insert statement with a ;
6th Apr 2021, 7:01 PM
sneeze
sneeze - avatar
0
You are amazing ! Thank you much i dropped this and it worked ! 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 ;
6th Apr 2021, 7:04 PM
Chris Frausto
Chris Frausto - avatar
0
Well done. Keep coding keep asking.
6th Apr 2021, 7:10 PM
sneeze
sneeze - 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:51 AM
Atul raj
Atul raj - avatar
0
If you are trying to do in Mobile app and it's not through the test case even though solution is perfect, try to do it on sololearn website.
22nd Jun 2022, 11:38 AM
Shravan Kumar
Shravan Kumar - avatar