I am not sure if I am apporaching this in the best way, but what I am trying to do is use two php variables for a IN clause in a mysql select query.
"select * from `user` where '$phpvar1' IN ('$phpvar2')"
Normally instead of $phpvar1 I would use a column name in the user table and it works fine, however in my case now I need the $phpvar1 variable to be used as a temporary column in this specific select query. Since $phpvar1 is dynamic in each situation, I do not want to store it. What can I do? Thanks!
EDIT: To clarify, $phpvar1 is not a column in the table, but I want it to act as one only for this one query. In this query I want $phpvar1 which is equal to for example: "cat", where as "cat" is the data that would be found in the column, and then this data ("cat") would be used in the IN clause to see if $phpvar2 contains "cat"
Basically what I want it to do is this:
SELECT * from `users` where 'mouse' IN ('cat', 'dog') and `userID` = '1'
the rows returned should have a userID = 1 AND meet the IN clause, since 'mouse' is not in ('cat,'dog') there won't be any rows returned in this case.
"select * from `user` where `$phpvar1` in ('$phpvar2')". Also how is your$phpvar2formed?$phpvar2? you can use a table less querySELECT 'cat' IN ('cat', 'dog')will return 1 andSELECT 'mouse' IN ('cat', 'dog')will return 0