How can I query using a foreign key in MySQL?

后端 未结 5 1389
暖寄归人
暖寄归人 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:18

    The easiest way would be through joins:

    select *
    from User u join Status s on u.status_id = s.id;
    

    (if you dont want the status-id at all, you can specify the columns that you do want in the select-clause.)

提交回复
热议问题