[size=medium][color=darkred]表1:两个字段
uuid code
1001 xxxx
1002 yyyy
表2:
uuid uuid1 uuid2
1 1001 1002
uuid1和uuid2是表1的uuid
现在我要写一个sql,通过表2查出uuid1和uuid2相对应的code,请问如何实现?
我自己想了很久,实在没办法了。[/color][/size]
select * from 表1
where 表1.uuid in
(
select distinct uuid1 from 表2
union
select distinct uunid2 from 表2
)
[quote]uuid code
1001 xxxx
1002 yyyy [/quote]
这个是不是有问题啊?你这是完成的表结构吗?主键是uuid?难道只能有两条数据?不懂你说的是什么意思
主键是哪个喔?