我不知道如何解决这个问题:
我有两张桌子
第一张桌子:
登记
=====================================================
ID NAME Mailid Subject_id username..password etc
-----------------------------------------------------
34 John xx 1 xxx
17 Mike xxx 2 xxx
5 Alan xxx 4 xxx
10 Dave xxxx 3 xxxx
第二桌
subject_id subject
1 maths
2 science
3 chemistry
4 physics
我想得到这样的结果
ID NAME Mailid Subjectname username..password etc
-----------------------------------------------------
34 John xx maths xxx
17 Mike xxx science xxx
5 Alan xxx physics xxx
10 Dave xxxx chemistry xxxx
我想要的是主题名称,而不是主题ID。
table1
=您的第一个包含用户详细信息的表。
table2
=您的第二张表包含主题详细信息。
SELECT table1.id, table1.name, table1.mailid, table2.subjectname, table1.username, table1.password, ......
FROM table1
LEFT JOIN table2 ON table1.subject_id = table2.subjectname
GROUP BY table1.id
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句