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 ?
14 RĂ©ponses
+ 1
Thank you so much for your help!
+ 1
This is where im at
+ 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
;
+ 1
I am missi f the order by?
+ 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
;
+ 1
When i added the insert to statement i got an error again
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.
0
Its still showing as wrong says there is a problem with the select statement
0
Yes. In the problem description it says.
Sorted by countries
That is an order by
0
end the insert statement with a ;
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
;
0
Well done. Keep coding keep asking.
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;
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.