So, i have two tables
fahrlehrer(id_f,first name,last name)
and
fahrschueler(id,first name, last name,id_f).
I have the last name of a column in fahrlehrer.
now my task is to show the first name and last name of all fahrschueler that have the FK of the the given name
my idea so far is:
select fahrschueler.nachname, fahrschueler.vorname
from fahrschueler
join fahrlehrer
on fahrschueler.fahrlehrernr = (select fahrlehrernr from fahrlehrer where nachname = "Blechle");
My guess is that the brackets are set wrong as im not sure of the syntax, glad the learn the right syntax
if there is something unclear lmk
edit:
i dont have datas, my task says: give out all first and last names of fahrschueler if their fahrleher’s name is "Blechle"
the output shouldnt be a help since the output is only the names
2
Answers
You can do it using
inner join
to join your tables into one as follows :Join the 2 tables using the
id_f
and its alway best to use single quotes in a query around a string.