好吧,在我在这里的第一个问题之后,我得到了以下正确且经过测试的代码:
SELECT DISTINCT
id, title, description, expires,
creator_id,executer_id,
oc_opentask.priority_id,
oc_opentask.status_id, priority_name, status_name,
oc_user1.username AS executer_username,
oc_user2.username AS creator_username
FROM oc_opentask
INNER JOIN oc_opentask_priority
ON oc_opentask.priority_id=oc_opentask_priority.priority_id
INNER JOIN oc_opentask_status
ON oc_opentask.status_id=oc_opentask_status.status_id
INNER JOIN oc_user AS oc_user1
ON oc_opentask.executer_id=oc_user1.user_id
INNER JOIN oc_user AS oc_user2
ON oc_opentask.creator_id=oc_user2.user_id
我的下一个问题是:我想访问它们executer_username
并creator_username
使用 WHERE 属性将其与值进行比较,所以我正在尝试的是:
SELECT DISTINCT
id, title, description, expires,
creator_id,executer_id,
oc_opentask.priority_id,
oc_opentask.status_id, priority_name, status_name,
oc_user1.username AS executer_username,
oc_user2.username AS creator_username
FROM oc_opentask
INNER JOIN oc_opentask_priority
ON oc_opentask.priority_id=oc_opentask_priority.priority_id
INNER JOIN oc_opentask_status
ON oc_opentask.status_id=oc_opentask_status.status_id
INNER JOIN oc_user AS oc_user1
ON oc_opentask.executer_id=oc_user1.user_id
INNER JOIN oc_user AS oc_user2
ON oc_opentask.creator_id=oc_user2.user_id
WHERE oc_opentask.creator_username='bill'
bill 确实存在于 db 中,但我访问该值的命令不正确,any1 可以帮助我吗?谢谢