如何根据主表中的 id 从另一个表中选择另外两个列


How to select two additional columns from another table based on id in the main table?

如何根据主表中的 id 从另一个表中选择另外两列?

SELECT t1.*, t2.*
FROM tbl_setup t1, tbl_specialty t2
WHERE t1.app_id = 12

使用 JOIN:

SELECT * FROM tbl_setup t1 
JOIN tbl_speciality t2
ON t1.app_idd = t2.t1_app_id

我不确定,但我认为您以后不能在 MySQL 列名称中使用"$"而不会遇到问题。

MySQL Joins的一个很好的解释:

http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/

相关文章: