开发者

Can this be done in one query?

开发者 https://www.devze.com 2023-02-07 13:46 出处:网络
table id (primary) key1,key2,key3 (secondary) given id N query #1 select key1,key2,key3 from开发者_C百科 table where id=N--key1n,key2n,key3n

table

id (primary)
key1,key2,key3 (secondary)

given id N

query #1

select key1,key2,key3 from开发者_C百科 table where id=N  --  key1n,key2n,key3n

query #2

select * from table where key1 = key1n and key2 = key2n  --  results...


SELECT  t2.*
FROM    table t1
JOIN    table t2
ON      t2.key1 = t1.key1
        AND t2.key2 = t1.key2
        AND t2.key3 = t1.key3
WHERE   t1.id = '$N'
0

精彩评论

暂无评论...
验证码 换一张
取 消