Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:23:31+00:00 2026-06-10T11:23:31+00:00

when binding a comma separated list of id’s to my prepared statement i only

  • 0

when binding a comma separated list of id’s to my prepared statement i only get one row returned, whereas I expected 3.

<?php

$dbh = new PDO("mysql:host=127.0.0.1;dbname=database", "user", "password");
$stmt = $dbh->prepare('SELECT * FROM Person WHERE PersonID IN (:p)');
$stmt->bindValue(":p", "3,4,5");
$stmt->execute();
$result =  $stmt->fetchAll(PDO::FETCH_ASSOC);

?>

<pre>
<?php print_r($result); ?>
</pre>

if I change the stmt to

SELECT * FROM Person WHERE PersonID IN (3,4,5)

i get back 3 rows as expected, I’m confused !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:23:32+00:00Added an answer on June 10, 2026 at 11:23 am

    Because bind will essentially wrap that in quotes and treat it as a single value. Then MySQL is converting it back to an integer so it still finds a match for the first item.

    You need to do IN (:p1, :p2, :p3) and bind value each separately

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom model binder that takes a comma separated list and cleans
I got some problem with binding some parameters in MYSQL statement in php. It
After binding the scroll event to an object, how can I get the amount
1) Binding to The following populates a READ ONLY WinFrms grid: Dim query =
I'm binding the jQuery-ui autocomplete to more than one element in my page as
Binding a ListView: ItemsSource={Binding Path=DF.DocFieldEnum1rows, Mode=OneWay}. DF.DocFieldEnum1rows is List<DocFieldEnum1row> . Item template binding: <Button
Binding a List collection to a datagrid. How can you limit what properties will
So I'm binding a list of custom business objects to a Rad chart, for
When binding values to controls I have plenty of this: Text='<%# Bind(StartDate, {0:dd.MM.yyyy}) %>'
When Binding a GridView to a DataTable, How can we Change the value displayed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.