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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:32+00:00 2026-05-23T23:16:32+00:00

I want to get rows from database. I am using the following query: select

  • 0

I want to get rows from database. I am using the following query:

select * from Table where  columnB = '1' AND '3';

I want to get rows in which column A has the same value and columnB is either 1 and 3. I don’t want any single row of columnA.

I want to retrieve rows in pairs on the basis of value in column A. There should no single row with value of column A

  • 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-23T23:16:32+00:00Added an answer on May 23, 2026 at 11:16 pm

    EDIT: Still not sure I understand your question, but…

    if you want all rows with B=’1′ such that there’s also another row with B=’3′ and both rows have the same value of A, as well as all rows with B=’3′ such that there’s also another row with B=’1′ and both rows have the same value of A, then something like this should work:

    select * from Table as t1
    where columnB = '1'
      and exists (
        select * from Table as t2
        where t2.columnA = t1.columnA
          and t2.columnB = '3'
      )
    UNION
    select * from Table as t3
    where columnB = '3'
      and exists (
        select * from Table as t4
        where t4.columnA = t3.columnA
          and t4.columnB = '1'
      )
    

    Your output will be something like this:

    | ColumnA | ColumnB |
    |   foo   |    1    |
    |   foo   |    3    |
    |   bar   |    1    |
    |   bar   |    3    |
    |   cat   |    1    |
    |   cat   |    3    |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQLServer 2008 and if I perform the following query: SELECT * FROM
I have a number of rows from a database which I want to insert
I have a table and I am hiding some rows. I want to get
I have a non-nullable database column which has a default value set. When inserting
I have a weird problem. i fetch some rows from database using: while($tag =
I have a database with a table which includes among others, one column of
I have identified a way to get fast paged results from the database using
I'm using the following code to query my database: private const int PAGE_SIZE =
I am trying to make a query to get data from a database, but
I'm using the following database: CREATE TABLE datas (d_id INTEGER PRIMARY KEY, name_id numeric,

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.