我想取结果,如果我有

$category ='doctor'

那我怎么才能得到结果呢?我已经画了下面的表格和预期的结果,请帮助我。谢谢
table name->Master
------------------

id        label        category

1       expertise       doctor
2          fee          doctor
3       appontment      doctor
4       services        lawyer
5       qualification   student





table name->Field
------------------

id       label_id      Information
1           1           desntist
2           1           general_physician
3           1           general_surgeons
4           4           criminal_law
5           5           civil_law



expected result
--------------------
 expertise

dentist
general_physician
general_surgeons

最佳答案

像这样做

select f.information as 'expertise'
from field f
join  master m on m.id = f.label_id
where m.category = 'doctor';

关于mysql - 我想从2个不同的表中获取数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35861076/

10-10 06:37