|Hello there. First let me give the 3 tables' definitions then I ask question.
In 3rd table, you can see that I am using boolean column which tells whether this Order belongs to guest user or member user. I want to select corresponding data using ONE QUERY. Here is what I have tried so far but it is far from working
SELECT O.*, CASE WHEN O.IsUserMember = 1 THEN U.UserName ELSE M.MemberName END <br />
FROM Orders O, CASE WHEN O.IsUserMember = 1 THEN Users U ELSE Members M END <br />
WHERE CASE WHEN O.IsUserMember = 1 THEN O.UserId = U.UserId ELSE B.UserId = M.MemberId END;<br />
It is giving me this following error:
Syntax error near 'CASE WHEN B.IsThisUserMember = 1 THEN Users U ELSE Members M END WHERE CASE WHEN' at line 1
NOTE: If I remove first CASE condition, then I get
empty set. Thanks for whatever you share.