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

  • Home
  • SEARCH
  • 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 6689741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:33:18+00:00 2026-05-26T05:33:18+00:00

Using SQL Server I want to check two values in two table. I have

  • 0

Using SQL Server

I want to check two values in two table.

I have two integer value (value1, value2)

Table1

ID Value

001 200
002 300
...

Table2

ID Value

001 300
002 400
...

Now I want to check whether value1 and value2 is matching with table1 value and table2 value

Tried Query

SELECT value from table1 Where  id = '" & textbox1.Text & "'

Condition

I want to check whether the value1 is matching with table1 or table2, then value2 is matching with table1 or table2. If it is matching then show the value otherwise null.

How to make a query.

Need Query help

  • 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-26T05:33:18+00:00Added an answer on May 26, 2026 at 5:33 am
    SELECT
        MAX(T1.ID)
    FROM
        (
        SELECT TOP 1 ID
        FROM table1 WHERE value = @Value1
        ORDER BY ID
        ) T1
        JOIN
        (
        SELECT TOP 1 ID
        FROM table2 WHERE value = @Value2
        ORDER BY ID
        ) T2 ON T1.ID = T2.ID
    

    Notes:

    • Use parameters for value1, value2
    • The MAX here will return a NULL if not found
    • This code looks for matches on value1 and value2 with the same ID

    For the last point, if you want any match

    SELECT
       MAX(1)
    FROM
        (
        SELECT TOP 1 ID
        FROM table1 WHERE value = @Value1
        ORDER BY ID
        ) T1
        CROSS JOIN
        (
        SELECT TOP 1 ID
        FROM table2 WHERE value = @Value2
        ORDER BY ID
        ) T2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[using SQL Server 2005] I have a table full of users, I want to
Using SQL Server 2000 I Want to Check the colum value whether it is
Using VB.Net and Sql Server I want to check the user Entry Value. The
Using SQL Server 2005 I want to filter the column where column value not
I am using SQL Server 2005. I want to constrain the values in a
I'm using SQL Server 2008. I have a database table that looks like this
Using SQL Server 2K8 R2, I have two related tables - Member and Questionnaire.
I have multiple string values, I want to insert in an sql server db
I'm using SQL Server and I want to use identity constraint in it I
I am using SQL Server 2005, I want to find out what all the

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.