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 394221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:20:04+00:00 2026-05-12T16:20:04+00:00

I have a database where users can search for records that have one or

  • 0

I have a database where users can search for records that have one or more of a list of items. I’m using IN to do the search, but I can’t get IN to work with prepared statements. This is what I’ve tried:

SELECT * FROM tbl1 WHERE col IN (?)

But the prepared statement treats the list of items I pass it as a single item. How can I make this work?

I’m using sqlite, if it makes any difference.

  • 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-05-12T16:20:04+00:00Added an answer on May 12, 2026 at 4:20 pm

    You can’t do IN this way, because you can’t bind to an array.

    You have to do it in two steps:

    1. Create the SQL with one ‘?’ per value in the array or list.
    2. Loop over the array or list and bind each value.

    This is true regardless of database.

    You don’t say whether a sub-SELECT could be a better solution, but perhaps it could be made to work if the values in question were available in another table.

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

Sidebar

Related Questions

I'm using a MySQL database. I have a products database where users can search
If i have items stored in a database that users can download after they
I have a database with Users. Users have Items. These Items can change actively.
I have a database of users where they can send messages to other users
I have a database with users and games. 1 game can have multiple users
I have a database where you can select articles etc, users have an account,
I have a resource database where resources can belong to different locations. Users and
Can I order my users in the database, so I don't have to say
I have a database that uses codes. Each code can be anywhere from two
Imagine the following (simplified) database layout: We have many holiday records that relate to

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.