Add only some IDs to MYSQL Query
I got the following code and like to add a part, which controls which IDS
should be shown. Each row has an ID, and i would like to enter for example
the ID 3,4 and 7 to show up. Any ideas how i can do this? Thanks a lot!
$itemsStmt = $pdo->query(
'SELECT '
. '*, '
. 'COUNT(v.voting_weight) AS cStimmen '
. 'FROM abl_gewinnspiel g '
. 'LEFT OUTER JOIN votes v '
. 'ON '
. 'v.vote_item_id = g.ID '
. 'GROUP BY g.ID '
. 'ORDER BY cStimmen DESC');
$voteItems = $itemsStmt->fetchAll();
Thought about . 'WHERE ID = (23,45,56)', But it does not work.
No comments:
Post a Comment