Sergii Rechmp
Sergii Rechmp

Reputation: 309

How to replace one field of table with another?

I have a problem with my self-made search page. There is 2 tables:

**name status**
Kevin 111       <-table1
Lucas 222

**id  data**
111 student     <-table2
222 pupil

So u need query that will give me table like that:

Kevin student
Lucas pupil

Thanks for help!

Upvotes: 0

Views: 96

Answers (1)

Marco
Marco

Reputation: 57593

Try this

SELECT t1.name, t2.data 
FROM table1 t1 INNER JOIN table2 t2
    ON t1.status = t2.id
ORDER BY t1.name

Upvotes: 2

Related Questions