0
我有兩個表如下(MYSQL)MySQL的子查詢兩次或兩次以上
條目表
Event_id | Horse_id | Place
101 101 1
101 102 2
101 201 3
101 301 4
102 201 2
103 201 3
201 101 1
301 301 2
401 102 7
HORSE表
Horse_id Name
101 Flash
102 Star
201 Boxer
301 Daisy
401 Snowy
我需要列出horse_id和名稱(1,2或3)兩次或更多的馬匹。 最好我能想出這是不是靠近它,我知道(需要做一個子查詢)
select horse_tbl.horse_id, horse_tbl.name
from horse_tbl
left join entry_tbl
on horse_tbl.horse_id = entry_tbl.horse_id
where place<4(
select count(horse_id)>1));
任何幫助,將不勝感激
感謝您的答覆添。在編寫查詢時,字母h和e如何工作。很明顯,h是horse_tbl,e是entry_tbl,這個替代品是否將名字寫出來? – Rbangs78
是的,這些是表別名。 –
工作很好,非常感謝。 – Rbangs78