【发布时间】:2015-05-11 10:28:24
【问题描述】:
我有两张桌子table1 和table2:
table1:
id (primary key)
name
email
category1 (foreign key to table2.id)
category2 (foreign key to table2.id)
category3 (foreign key to table2.id)
table2:(类别)
id (primary key)
name
我想编写一个选择查询来获取类别名称而不是 categoryId。
【问题讨论】:
-
您能否提供一些有关您的表格的数据?您的开场问题有点令人困惑。
-
您从哪里获得 CategoryName?我在table2中也找不到!
-
table1 字段:id、name、email、category1(类别表中的id)......
-
table2 字段 : id , name.....
-
我想要一个查询来获取包含 id 的类别名称