How can I query using a foreign key in MySQL?

后端 未结 5 1348
暖寄归人
暖寄归人 2020-12-31 03:54

Right now I have a small database with two tables that look something like this:

    users table
    ====================
    id  name   status_id
    1   Bo         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 04:29

    What you need is this

    SELECT *
    FROM `users`
    JOIN statuses ON statuses.id = users.status_id
    WHERE `status_id` = 2";
    

    and then you can refer to

    $row['value'];
    

提交回复
热议问题