我想知道這種 make 查詢是否有名稱,哪個是更好的選擇?
選項1
select * from users, tasks
where users.id = tasks.user_id
and user.name='Lucas'
選項 2
SELECT * from task
where user_id in (select id in users where user.name='Lucas')
選項 3
SELECT *
FROM tasks
JOIN users
ON tasks.user_id = users.Id
where user.name='Lucas'
謝謝
uj5u.com熱心網友回復:
連接表時,我通常使用連接。(此處為選項 3)
在性能方面,我認為選項 1 和 3 之間沒有太大區別。至于第二個選項,我幾乎在所有情況下都會避免使用它。
我認為這篇文章更詳細地回答了你的問題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/476018.html
標籤:mysql sql PostgreSQL
下一篇:在JSONB中添加布爾欄位
