SELECT a.* FROM auctioncommendity a
LEFT JOIN auctionbid b
ON a.id=b.auctioncommendityid AND a.id='000000004ef2f390014ef3024f230015';
SELECT a.* FROM auctioncommendity a
INNER JOIN auctionbid b
ON a.id=b.auctioncommendityid AND a.id='000000004ef2f390014ef3024f230015';
這是因為你第一個語句用的是left join。
而left join後面的on的條件 AND a.id='000000004ef2f390014ef3024f230015' 只是用於限制 a在和b關聯時,用a中的 滿足條件的數據和b關聯,那麼a中 a.id 不等於'000000004ef2f390014ef3024f230015'的仍然會顯示出來,只是 b的哪些列 都是null而已。
要用left join來實現 inner join的效果,可以這麼寫:
SELECT a.* FROM auctioncommendity a
left JOIN auctionbid b
ON a.id=b.auctioncommendityid
where a.id='000000004ef2f390014ef3024f230015';
等價於你寫的這個:
SELECT a.* FROM auctioncommendity a
INNER JOIN auctionbid b
ON a.id=b.auctioncommendityid AND a.id='000000004ef2f390014ef3024f230015';