I have been attempting to figure out where I can SET a variable in an SQLQuery. I have 2 different select statements that will have a different WHERE clause depending on the answer to an IF statement, but I would like to only have to run the query to make SET this variable once, and since I am already running the code to find this particular table, I'd like to do it in the first SELECT statement.
The variable I am trying to SET is called regType
SELECT S.subID, C.cKey FROM Comp AS C JOIN JData AS J ON J.pKey = C.primary JOIN Sub AS S ON J.fKey = S.pKey WHERE ( //This is where I need the variable// )
I want to create a variable because I have a second SELECT that uses the same WHERE clause with the same conditions on it.
Where in this can I SET a variable within the SELECT statement so that I can use it in my WHERE?