Okey我正在尝试加入一些桌子,但没有运气。 我设法加入他们,但它显示重复!(?)
正如你可以在表二,列日期,我想排序 结果。但同样,以下查询没有运气:
SELECT traning.uid, traning.type, traning.duration, users.user_id, users.user_name,traning_type.type_id, traning_type.name
FROM traning
INNER JOIN users
ON traning.uid=users.user_id
INNER JOIN traning_type
ON traning.type=traning_type.type_id
下面是我要查询的表格布局和列。
table one users
----
user_id user_name
table two training
----
id uid type min_puls medel_puls max_puls duration date
table three traning_type
----
type_id name
训练表中的uid是来自users表的user_id,训练中输入的是来自traning_type的type_id。
非常感谢帮助!
答案 0 :(得分:0)
您的数据库图表不正确
table one users
----
user_id user_name
associative table(user_training)
user_id tr_id min_puls medel_puls max_puls duration date
table two training
----
tr_id type_name
SELECT training.type_name,users.user_id,users.user_name,
user_training.min_puls,user_training.medel_puls,user_training.max_puls,
user_training,duration, user_training.date
FROM training INNER JOIN user_training
ON training.tr_id=user_training.tr_id
INNER JOIN users ON user_training.user_id=users.user_id