Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
user_infoテーブル:
user_info
ui_id
name
created_by
usersテーブル:
users
user_id- PK
user_id
username
user_infoテーブルの内容を表示したい。created_byフィールドはusers テーブルのsです。表示するときuser_idに変更したいと思います。username
単一のクエリで可能ですか?方法を教えてください。
これでいいだろう
select ui.*, u.username from user_info ui join users u on u.id = ui.created_by
テーブルを結合するだけです。