select all columns which are not in another table laravel 5.5

后端 未结 4 1369
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 04:05

I have two tables - the first one is called \'users\' and the second one is called \'buy_courses\'.

I am trying to select all users those user_name

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 04:24

    You can use SQL's 'NOT IN'.

    Example:

    mysqli_query($con, "SELECT * FROM users WHERE user_name NOT IN (SELECT user_name FROM buy_courses)");
    

提交回复
热议问题