日期:2014-05-17 浏览次数:20474 次
CREATE TABLE test (id int ,hezhi int ) INSERT INTO test SELECT 1, 26 UNION ALL SELECT 2, 25 UNION ALL SELECT 3, 15 UNION ALL SELECT 4, 6 UNION ALL SELECT 5, 6 SELECT * FROM test a WHERE EXISTS ( SELECT 1 FROM (SELECT id FROM test WHERE hezhi=6 ) b WHERE a.id BETWEEN b.id-1 AND b.id+1 ) /* id hezhi ----------- ----------- 3 15 4 6 5 6 (3 行受影响) */