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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:11:02+00:00 2026-06-04T11:11:02+00:00

This is a summary of what I am trying to do: $array[0] = 1;

  • 0

This is a summary of what I am trying to do:

$array[0] = 1;
$array[1] = 2;

$sql = "SELECT * FROM table WHERE some_id = $array"

Obviously, there are some syntax issues, but this is what I want to do, and I haven’t found anything yet that shows how to do it.

Currently, my plan is to do something along these lines:

foreach($idList as $is)
    $where .= 'some_id=' . $id . ' OR';
endforeach

$sql = "SELECT * FROM table WHERE " . $where;

So is there support in PostgreSQL to use an array to search, or do I have to do something similar to my solution?

  • 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-04T11:11:04+00:00Added an answer on June 4, 2026 at 11:11 am
    SELECT  *
    FROM    table
    WHERE   some_id = ANY(ARRAY[1, 2])
    

    or ANSI-compatible:

    SELECT  *
    FROM    table
    WHERE   some_id IN (1, 2)
    

    The ANY syntax is preferred because the array as a whole can be passed in a bound variable:

    SELECT  *
    FROM    table
    WHERE   some_id = ANY(?::INT[])
    

    You would need to pass a string representation of the array: {1,2}

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

Sidebar

Related Questions

I am trying to understand some performance summary output from MSBuild. The results look
i'm trying to do this: #region COM Registration Methods /// <summary> /// Performs COM
I am using EF4 to read data from a view .This is a summary
My items are listed as follows; This is just a summary of course. But
I'm trying to do this: $('.summary').css('top',$(this).outerHeight()); Where I reference 'this' I would like to
I'm trying to add some functionality from a plugin I have made into a
I'm trying to convert a JSON object/array from the Google Directions API v3 to
I'm trying to add the articles id to the title, summary and content but
I'm trying to skip and take from a query, but get the casting errors:
This is probably not very elegant, but what I'm trying to do is connect

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.