I have F.FRIENDID, F.MEMBERID columns in FRIENDS table and M.MEMBERID, M.FIRSTNAME, M.LASTNAME in MEMBERS table. I want to list all friends' of signed in member. Issue here is, signed in member's ID can sometimes be in FRIENDID row or MEMBERID row in FRIENDS table. That is because when member adds another member, his or her ID is recorded in FRIENDID field, where other member's ID is recorded in MEMBERID field.
I tried couple of SQL queries. Neither worked. I think this query should have worked but it gives the following error.
SQL = "SELECT F.FRIENDID, F.MEMBERID, F.ACTIVE, M.MEMBERID, M.FIRSTNAME, M.LASTNAME, M.ACTIVE"
SQL = SQL & " FROM FRIENDS F, MEMBERS M"
SQL = SQL & " WHERE (F.FRIENDID OR F.MEMBERID) = "& Session("MEMBERID") &" AND (F.FRIENDID OR F.MEMBERID) = M.MEMBERID AND F.ACTIVE = 1 AND M.ACTIVE = 1"
SQL = SQL & " ORDER BY M.FIRSTNAME, M.LASTNAME ASC"
Set objFriends = objConn.Execute(SQL)
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'OR'.