MySQL - Select All Except what is in this Table

前端 未结 5 1440
青春惊慌失措
青春惊慌失措 2020-12-21 19:14

I am wanting to select all images that a user does not already have.

I have three tables: user, image, and user_image:

5条回答
  •  伪装坚强ぢ
    2020-12-21 19:55

    select id, date from image where id not in (select image_id from user_image where user_id =

    There is a faster way but this is easier to follow.

    Another way would be:

    select id, data from image left join user_image on user.id=user_image.user_id where user_image.id = null

提交回复
热议问题