有2张表:如图,
关联关系为:
B.pil_id = A.id
B.stu_id = A.id
B.tea_id = A.id我要如何用sql语句连接查询把B表pil_id、stu_id、tea_id对应的名字都查询出来
关联关系为:
B.pil_id = A.id
B.stu_id = A.id
B.tea_id = A.id我要如何用sql语句连接查询把B表pil_id、stu_id、tea_id对应的名字都查询出来
解决方案 »
- mysql字符集
- MYSQL数据库异常
- vs,mysql数据库打包的问题
- mysql 导入问题
- 有关mysql进入的问题
- 请问mysql数据库能不能实现oracle数据库PERCENT_RANK函数的功能?
- 求助!!!急!小女子先谢过了!!有关在mysql如何得到记录数的问题
- mysql备份问题!急
- VC++6.0编译MYSQL问题
- mysql执行错误use mysql update user Set user='ok',password=password('ok') where user='root'
- MySQL procedure cursor 如何遍历完
- mysql limit函数传参问题
(select name from a where id=pilid),
(select name from a where id=stu_id),
(select name from a where id=te_id)
from b
(select name from a where a.id=b.pilid),
(select name from a where a.id=b.stu_id),
(select name from a where a.id=b.te_id)
from b
(select name from a where a.id=b.pilid),
(select name from a where a.id=b.stu_id),
(select name from a where a.id=b.te_id)
from b
(select name from a where a.id=b.pilid),
(select name from a where a.id=b.stu_id),
(select name from a where a.id=b.te_id)
from b
(select name from a where a.id=b.stu_id) as stu_name,
(select name from a where a.id=b.tea_id) as tea_name
from b
SELECT ax.pil_id,bx.name FROM b ax,a bx WHERE ax.pil_id=bx.Id
UNION ALL
SELECT ax.stu_id,bx.name FROM b ax,a bx WHERE ax.stu_id=bx.Id
UNION ALL
SELECT ax.tea_id,bx.name FROM b ax,a bx WHERE ax.tea_id=bx.Id
(select name from A where A.Id=B.stu_id) as StuName,
(select name from A where A.Id=B.tea_id)as TeaName from B