Reputation: 7900
I have a table in sql, I use this statement to make a select:
SELECT id, name, genre FROM table
Now genre
is id (int) and I have table called Genres and there I have :
id (int)
name (string)
What select will give me in genre the name and not the id.
Upvotes: 0
Views: 841
Reputation: 4187
SELECT t.id, t.name, g.name
FROM table t
JOIN genres g ON t.genre = g.id
Upvotes: 2
Reputation: 223402
You need to use Join
select G.name
from table table1 T,Genres G
where T.genre = G.id;
Upvotes: 0
Reputation: 3229
SELECT t.id, t.name, g.name
FROM table t, genres g
WHERE t.genre = g.id
Upvotes: 1