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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:14:01+00:00 2026-05-27T00:14:01+00:00

How I can select a set of rows where each row match a different

  • 0

How I can select a set of rows where each row match a different condition?

Example:

Supposing I have a table with a column called name, I want the result ONLY IF the first row name matches ‘A’, the second row name matches ‘B’ and the third row name matches ‘C’.

Edit:

I want to do this to work without a fixed size, but in a way I can define the sequence like R,X,V,P,T and it matches the sequence, each one in a row, but in the order.

  • 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-27T00:14:01+00:00Added an answer on May 27, 2026 at 12:14 am

    Assuming that You know how to provide a row number to your rows (ROW_NUMBER() in SQL Server, for instance), You can create a lookup (match) table and join on it. See below for explanation:

    LookupTable:

    RowNum    Value
    1         A
    2         B
    3         C
    

    Your SourceTable source table (assuming You already added RowNum to it-in case You didn’t, just introduce subquery for it (or CTE for SQL Server 2005 or newer):

    RowNum Name
    -----------
    1      A
    2      B
    3      C
    4      D
    

    Now You need to inner join LookupTable with your SourceTable on LookupTable.RowNum = SourceTable.RowNum AND LookupTable.Name = SourceTable.Name. Then do a left join of this result with LookupTable on RowNum only. If there is LookupTable.RowNum IS NULL in final result then You know that there is no complete match on at least one row.

    Here is code for joins:

    SELECT T.*, LT2.RowNum AS Matched 
    FROM LookupTable LT2
    LEFT JOIN 
    (
        SELECT ST.*
        FROM SourceTable ST
        INNER JOIN LookupTable LT ON LT.RowNum = ST.RowNum AND LT.Name = ST.Name
    ) T
        ON LT2.RowNum = T.RowNum
    

    Result set of above query will contain rows with Matched IS NULL if row is not matching condition from LookupTable table.

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

Sidebar

Related Questions

I have multiple table rows that has a set of radio buttons on each
I have a table that contains multiple rows. Each row contains 5 columns (or
I have a table containing a large number of rows. Each row has 2
I have a databases table with ~50K rows in it, each row represents a
I have a Gridview in my page Which I can Select each row i
I have a table containing a large number of rows. Each row has 2
I have several lists, that you can consider as rows of integers. For example
I have a large table (2,000,000 rows) and I'd like to print each record
To Set up the scenario, Lets say I have 100000 rows in the table
Currently I have UNION's between 3 different select statements giving me three rows. What

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.