Efe
Efe

Reputation: 954

Multiple WHERE clauses in a SQL query

My code was working fine until I added another where clause, T.TokenType = facebook.

Can we have as many where clauses as we want?

Or did I mess it up elsewhere.

FYI, I have facebookID of a member and want to get his/her facebook access token and system memberID.

SQL = "SELECT M.MemberID, M.FacebookID, T.MemberID, T.TokenType, T.Token_Code"
    SQL = SQL & " FROM MEMBERS M, TOKENS T"
    SQL = SQL & " WHERE M.FacebookID = "& strUserID &" AND M.MemberID = T.MemberID AND T.TokenType = facebook"
    Set objMember = objConn.Execute(SQL)

Upvotes: 2

Views: 1173

Answers (5)

Jerry Hoerig
Jerry Hoerig

Reputation: 146

Are you getting an error? Normal sql will allow as many clauses as you wish so adding another shouldn't matter. Also, is token a String? If so it needs quotes.

Upvotes: 0

JohnFilleau
JohnFilleau

Reputation: 4288

Could it be that instead of

T.TokenType = facebook

You want

T.TokenType = 'facebook'

?

Upvotes: 2

Bart Friederichs
Bart Friederichs

Reputation: 33511

Probably, facebook isn't a column name. Try adding quotes:

AND T.TokenType = 'facebook'

Upvotes: 0

Nick Andriopoulos
Nick Andriopoulos

Reputation: 10643

you need to encapsulate string values in quotes, ie T.TokenType = "facebook"

Upvotes: 0

DarkAjax
DarkAjax

Reputation: 16223

facebook seems to be a string, so I'd say you're missing quotes, try changing T.TokenType = facebook with T.TokenType = 'facebook'. And yes you can have as many conditions as you want...

Upvotes: 2

Related Questions