A 表有多个 字段 比如A.a,A.b,A.c,A.d 字段值皆是表B的id 如何查询A.a A.b A.c A.d在B表对应的字段值

mysql
2025-12-17 11:54:15
推荐回答(4个)
回答1:

select id from b join a on b.id=a.a or b.id=a.b or b.id=a.c or b.id=a.d

回答2:

select * from
(select A.a,B.content as contentFora from A LEFT JOIN B on A.a=B.id) as table1
(select A.b,B.content as contentForb from A LEFT JOIN B on A.b=B.id) as table2
(select A.c,B.content as contentForc from A LEFT JOIN B on A.c=B.id) as table3
(select A.d,B.content as contentFord from A LEFT JOIN B on A.d=B.id) as table4

回答3:

SELECT m.*,n.path as coverPath,o.path AS cover1Path ,p.path AS cover2Path, a.path AS cover3Path ,p.path AS erweimaPath
FROM photo as m
INNER JOIN attachment as n on m.cover=n.id
INNER JOIN attachment as o on m.cover1=o.id
INNER JOIN attachment as p on m.cover2=p.id
INNER JOIN attachment as a on m.cover3=a.id
INNER JOIN attachment as b on m.erweima=b.id;

回答4:

什么鬼?打比方能不能专业点?