YosiFZ
YosiFZ

Reputation: 7900

Select in SQL with id parameter

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

Answers (3)

Manatherin
Manatherin

Reputation: 4187

SELECT t.id, t.name, g.name 
FROM table t 
   JOIN genres g ON t.genre = g.id

Upvotes: 2

Habib
Habib

Reputation: 223402

You need to use Join

 select G.name 
    from table table1 T,Genres G
    where T.genre = G.id;

Upvotes: 0

duncanportelli
duncanportelli

Reputation: 3229

SELECT t.id, t.name, g.name
FROM table t, genres g
WHERE t.genre = g.id

Upvotes: 1

Related Questions