Query IN() not working as intended
If I run the query:
SELECT board.id, board.name
FROM board
INNER JOIN group_assoc ON group_id
IN (
"4,9,12,15,18,21,22,55,57,83,84,86,89,92,95,98,104,105"
)
AND group_assoc.board_id = bo开发者_StackOverflow中文版ard.id
INNER JOIN category ON category.id = board.category_id
AND category.forum_id =2
I get a different result than
SELECT board.id, board.name
FROM board
INNER JOIN group_assoc ON group_id = 9
AND group_assoc.board_id = board.id
INNER JOIN category ON category.id = board.category_id
AND category.forum_id =2
Is it only pulling boards that can be viewed by all groups?
If the values in "IN" are integers, don't use double quotation marks (" "), like this
SELECT board.id, board.name
FROM board
INNER JOIN group_assoc ON group_id
IN (
4,9,12,15,18,21,22,55,57,83,84,86,89,92,95,98,104,105
)
AND group_assoc.board_id = board.id
INNER JOIN category ON category.id = board.category_id
AND category.forum_id =2
And if the values are strings, use double quotation marks for each string.
SELECT board.id, board.name
FROM board
INNER JOIN group_assoc ON group_id
IN (
"4121213","9434345443","12545454"
)
AND group_assoc.board_id = board.id
INNER JOIN category ON category.id = board.category_id
AND category.forum_id =2
Try IN (4,9,12,...)
精彩评论