1. 程式人生 > >mysql 查詢資料不一樣的現象

mysql 查詢資料不一樣的現象

使用mysql資料庫,資料一個表大概在400萬條左右,有id主鍵,將一部分select id from detail group by billno, iosort,barcode having count(*)>1 的資料寫到表test的id欄位,使用下列兩個查詢語句結果不一樣,求問了領導,說是可能記憶體溢位,使用了left join或者 inner join正常

test表記錄數在193萬條左右,第一條sql查詢出來的是193萬條, 第二條查詢出來的是93萬條,不知道為什麼不對,沒找到原因,改為left join查詢

select count(*) from test where id in (select id from detail )

select count(*) from detail where id in (select id from test)