我有一個表users
包括行MYSql:哪一個更適合獲得ROWS? (其中())或的foreach
現在,哪一個是更好的選擇?
A.
select *
from users
where user_id IN
(5,12,5979,124,455594,5444,..........4568,10001,546,9979,21315);
B.
`$user_ids = {5,12,5979,124,455594,5444,.......4568,10001,546,9979,21315};`
foreach ($user_ids as $id) {
select * from users where user_id = $id;
}
我想知道從這個
一個好的經驗法則是永遠不要在循環內執行查詢 – Strawberry