我有以下查询,其中的“ ID”字段不明确,我知道我需要使用别名,但是在第二个示例中使用别名时似乎做错了事
class SpecBuilder a b c where
expectation :: a -> b -> SpecWith c
specAll :: String -> [(a, b)] -> SpecWith c
specAll name items = describe name $ mapM_ (uncurry expectation) items
我已遵循一些在线示例,并在第二行得到了一个错误。
constructor(public navCtrl: NavController,private geolocation: Geolocation) {
navigator.geolocation.getCurrentPosition(this.onSuccess, this.onError);
}
onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
onSuccess(position) {
let element = document.getElementById('map');
element.innerHTML = 'Latitude: ' + position.coords.latitude + '<br />' +
'Longitude: ' + position.coords.longitude + '<br />' +
'<hr />' + element.innerHTML;
console.log(element)
}
请问有什么解决方法吗?
答案 0 :(得分:1)
请尝试以下查询
SELECT t1.ID
FROM 01users AS t1
INNER JOIN 01modules ON 01modules.Modules_UserID = t1.ID
INNER JOIN 01articles ON 01modules.ID = 01articles.ModuleID
WHERE User = '$user' AND t1.ID = '$moduleid'
ORDER BY WeekID ASC
您还需要在where
子句中使用别名。
此行
WHERE User = '$user' AND ID = '$moduleid'
更改为此
WHERE User = '$user' AND t1.ID = '$moduleid'
答案 1 :(得分:0)
学习使用表别名!
SELECT *
FROM 01users u INNER JOIN
01modules m
ON m.Modules_UserID = u.ID INNER JOIN
01articles a
ON m.ID = 01artacles.ModuleID
WHERE u.User = '$user' AND m.ID = '$moduleid'
ORDER BY ?.WeekID ASC
您应该对所有列引用进行限定,包括WeekId
-这就是?
的用途。
您还应该明确列出想要的列,而不要使用select *
。
答案 2 :(得分:0)
这是解决方案:
SELECT u.User, m.ID, a.Title, a.Topic, a.Text, a.WeekID, a.DatePosted, a.DateDue, a.TimePublished, a.File1, a.ID AS ArticleID
FROM 01users as u
INNER JOIN 01modules AS m ON m.Modules_UserID = u.ID
INNER JOIN 01articles AS a ON m.ID = a.ModuleID
WHERE User = '$user' AND m.ID = '$moduleid'
ORDER BY WeekID ASC