SELECT students.id, students.firstname, students.lastname, teachers.lastname AS teacher FROM students, teachers WHERE students.t | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

SELECT students.id, students.firstname, students.lastname, teachers.lastname AS teacher FROM students, teachers WHERE students.t

What is Error in the code?

22nd Apr 2024, 11:27 AM
Sonal Kumar
Sonal Kumar - avatar
5 Answers
+ 1
Error show on the code
22nd Apr 2024, 12:02 PM
Sonal Kumar
Sonal Kumar - avatar
+ 1
Sonal Kumar Please write / paste your code into the message body, not the title. Your code is too long and can't show the complete code.
22nd Apr 2024, 2:14 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
You need to add a join condition using the ON clause to indicate on which columns the tables should be joined. For instance if you have a teacher_id column in the students table that refers to the teacher's identifier in the teachers table here is the code: SELECT students.id, students.firstname, students.lastname, teachers.lastname AS teacher_lastname FROM students JOIN teachers ON students.teacher_id = teachers.id;
22nd Apr 2024, 11:52 AM
piano T
0
can you display your code? in full What kind of error does it give you?
22nd Apr 2024, 12:08 PM
piano T
0
It seems like your WHERE clause is incomplete, so it's difficult to determine the exact error without knowing the full condition you intend to apply. Also the query has no join condition between the students and teachers tables, so it couldn't result in a Cartesian product (cross join) of the two tables. You should complete the WHERE clause with a valid condition and add a proper join condition to relate the students and teachers tables
22nd Apr 2024, 1:54 PM
`нттp⁴⁰⁶
`нттp⁴⁰⁶ - avatar