SQL ZOO | SoloLearn: Learn to code for FREE!

-3

SQL ZOO

Hi, can you please help me with this query? Thank you 1) A new animal has come in, with the following details: name - "Slim", type - "Giraffe", country_id - 1 Add him to the Animals table. 2) You want to make a complete list of the animals for the zoo’s visitors. Write a query to output a new table with each animal's name, type and country fields, sorted by countries.

12/20/2020 7:45:27 PM

Sort Ravn

27 Answers

New Answer

+11

Thank you HBhZ_C I thought that I have to do it one by one. So solution for it is: 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

+5

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;

+3

yes, but it is the last task and I cant find anything wrong with my query INSERT INTO Animals (name, type, country_id) VALUES ('Slim', 'Giraffe', 1); that is for the task 1) and I cant see the mistake

+3

But your code is not complete you have to use inner join to display the table as they give in the test cases order by country ....

+1

/* name - "Slim", type - "Giraffe", country_id - 1 */ 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 country;

0

Glad to see that you found the solution by your single effort and gain SQL certif.congrat.

0

it seems you must write all the queries for both parts first.

0

insert into Animals values ('Slim', 'Giraffe', 1); select name, type, country from Animals join Countries on Animals.country_id = Countries.id order by country;

0

I can't get It to work also, i even tried a simple select * from Animals, but It says no output, it's driving me crazy

0

select animals.name, animals.type, countries.country from animals inner join countries on animals.country_id=countries.id order by countries.country;

0

Henry Fantacussi I got it right, its in the comments above

0

INSERT INTO Animals VALUES ('Slim','Giraffe',1); SELECT Animals.name,Animals.type,Countries.country FROM Animals,Countries INNER JOIN Countries ON Animals.country_id=Countries.id ORDER BY Countries.country; Not working.

0

remove ...FROM Animals,Countries... table Countries cuz you joining it to Animals. Rest of query is correct

0

Thank you Sort Ravn

0

with slightly different syntax /* 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 Countries.country;

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 countries.country My query is getting correct output but not selected as correct solution any idea why?

0

Вы хотите арендовать апартаменты и у вас есть таблица Apartments:

0

hi Sort Ravn can you please 9

0

1, INSERT INTO Animals (name,type,country_id) VALUES ('slim','girafe',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 * 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

0

hi Sort Ravn can you please help me with two query? the difference between them, because sentence 1 is wrong,thanks you so much