0

I dont see the Error here please find it for me

INSERT INTO ANIMALS(name,type,country_id) VALUES ("Slim","Giraffe",1); SELECT * FROM ANIMALS INNER JOIN ANIMALS ON countries.id = Animal.country_id ORDER BY Animal.country_id

4th Apr 2023, 4:10 AM
ARBEIT MANN
ARBEIT MANN - avatar
4 Answers
0
The error in the code is that the table name is not specified in the second occurrence of ANIMALS in the SELECT statement, causing a syntax error. I see you countries.id = Animal.country_id but in the INNER JOIN you use the same name maybe changing it like this will make the error go away. ------------------------------------------- SELECT * FROM ANIMALS INNER JOIN COUNTRIES ON COUNTRIES.id = ANIMALS.country_id ORDER BY ANIMALS.country_id;
4th Apr 2023, 4:28 AM
Minh LÆ°u
Minh LÆ°u - avatar
0
Ohk
4th Apr 2023, 3:55 PM
ARBEIT MANN
ARBEIT MANN - avatar
0
It says the coluomn slim does not exist
4th Apr 2023, 3:58 PM
ARBEIT MANN
ARBEIT MANN - avatar
0
The error is in the second line. When inserting values into a table, you should use single quotes for string values instead of double quotes. Therefore, your statement should be: INSERT INTO ANIMALS(name,type,country_id) VALUES ('Slim','Giraffe',1); Also, in the SELECT statement, you have used the same alias ANIMALS for both tables which is not allowed. You should use a unique alias for each table. Try the below query instead: SELECT * FROM ANIMALS INNER JOIN COUNTRIES ON COUNTRIES.id = ANIMALS.country_id ORDER BY ANIMALS.country_id; This assumes that you have a COUNTRIES table with an id column that matches the country_id column in the ANIMALS table.
5th Apr 2023, 2:32 AM
Z3ro