I am trying to create a work-flow with the help of SQL CE Database.
**Usr Table**
UID FName LName
1 Tim Lake
2 June Stone
**WFlow Table**
fID Topic InitBy ApprovBy PostedBy
1 Topic 1 2 NULL NULL
2 Topic 2 1 NULL NULL
UID and fID are Primary Keys and InitBy, ApprovBy, PostedBy are Foreign Keys linked to UID.
Now once the first topic is created fID=1, Topic=Topic 1, InitiBy=2, ApprovBy=NULL, PostedBy=NULL.
my SQL CE query looks like this.
Select WF.fID, WF.Topic,
U1.FName + U1.LName as InitiBy,
U2.FName + U2.LName as InitiBy,
U3.FName + U3.LName as InitiBy,
from WFlow WF, Usr U1, Usr U2, Usr U3
where W.InitiBy = U1.UID
and W.ApprovBy = U2.UID
and W.PostedBy = U3.UID
This query returns no result. I am not able to handle the NULL in the ApprovBY and PostedBy columns.
appreciate your help.
Thanks,
i would also like to know how different the query will be in mySQL. in SQL-CE someone was able to help with the LEFT JOIN clause. but it does not seem to work in mySQL.
You need to use
LEFT JOINfor thisSQLFiddle Demo