Well after my first question here I came the below code which is correct and tested:
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
My next question is: I want to access those executer_username and creator_username with a WHERE attribute to compare it with a value, so what I am trying which is poping mystake is:
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 does exists in db, but my command to access that value is not correct, can any1 help me on this? Thanks
You are using wrong table to get the creator name in the where clause. Use
oc_user2table to get the user name(creator name). Also I am just thinking still there may be acaserelated issue and hence advice to useLOWERfunction before comparison and as below:I just user
LOWERon right side to make it case independent forany valid nameirrespective of the case.