jeudi 17 septembre 2015

Doubts about my SQL quires in SQL exercise (Unable to find the column)

I am recently doing the sql exercise and its requirement is as follows:

For every situation where student A likes student B, but we have no information about whom B likes (that is, B does not appear as an ID1 in the Likes table), return A and B's names and grades.

And I have a reference about the schema: http://ift.tt/1F5NZAZ

and my query is as follow:

select h1.name, h1.grade, h2.name, h2.grade from highschooler h1, highschooler h2, likes l1, likes l2 where h1.id in (select id1 from l1 where not exists ( select id2 from l1 where id2 = id1)) and h2.id in (select id2 from l2 where not exists ( select id2 from l2 where id2 = id1))

The SQL is built in html server and it keeps telling me that they are unable to find column l1. Is there any logical error in my code and can someone tell what's wrong with it? Thx!

Aucun commentaire:

Enregistrer un commentaire