Can this be done in one query?
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'
精彩评论