MySQL select specific entry from a table which is not in another table

后端 未结 3 686
旧巷少年郎
旧巷少年郎 2021-01-21 12:15

I have a problem in MySQL when trying to select specific entry from table which is not in another table. I know this sentence sounds nuts but here is an example what I am trying

3条回答
  •  孤城傲影
    2021-01-21 13:05

    doing NOT IN queries are not typically great for performance... instead, using LEFT JOIN and looking for NULL would be better.

    select 
          u.User_ID
       from 
          Users U
             LEFT JOIN Views V
                on U.User_ID = V.User_ID 
               AND v.Article_ID = 10
       where
          V.User_ID IS NULL
    

提交回复
热议问题