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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:08:35+00:00 2026-05-29T06:08:35+00:00

Please consider this Query: SELECT tesd.State_Code, tesd.City_Code, tesd.Row_ID, tesd.Qsno, tesd.Total_Period, tesd.Current_Period, tesd.Week, tesd.Block_No, tesd.Family_ID,

  • 0

Please consider this Query:

SELECT tesd.State_Code,
   tesd.City_Code,
   tesd.Row_ID,
   tesd.Qsno,
   tesd.Total_Period,
   tesd.Current_Period,
   tesd.Week,
   tesd.Block_No,
   tesd.Family_ID,
   tesd.Line_ID,
   tesd.Page_ID
   INTO #tmp
FROM   Specification_Master tesm
   INNER JOIN Specification_Details tesd
        ON  tesd.Master_Id = tesm.Id
WHERE  tesm.[Year] = 2000
   AND tesm.[Month] = 10
   AND tesd.City_Code IN ('001')

I queried some data from 2 tables and insert them in #tmp .then I want to select data from 2 other tables and check one of that tables has values in #tmp tbale:

SELECT *
FROM   tbl_Details D
   INNER JOIN tbl_Master tem
        ON  D.ID_Master = tem.Id
WHERE  D.Period <= 5
 AND EXISTS (
           SELECT Row_ID
           FROM   #tmp tm
           WHERE  tm.Current_Period > 1
                  AND tm.State_Code = tem.State_Code
                  AND tm.City_Code = tem.City_Code
                  AND tm.Qsno = tem.Qsno
       )
   AND D.[Status] > 2 

when I run this query I got just one row but when I change EXISTS to NOT EXISTS I got more rows.I run this query seperatly :

SELECT Row_ID
           FROM   #tmp tm,tbl_Master tem 
           WHERE  tm.Current_Period > 1
                  AND tm.Ostan_Code = tem.State_Code
                  AND tm.City_Code = tem.City_Code
                  AND tm.Porseshname_ID = tem.Qsno

and it returns 30 rows. Why Exists has this such behaivior ?

  • 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-29T06:08:35+00:00Added an answer on May 29, 2026 at 6:08 am

    Exists returns a Boolean value based on the results of the subquery. It matters not if there are 1 or 30 rows returned. The number of rows you are retrieving is based on the select * statement, not the Exists clause.

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

Sidebar

Related Questions

Please consider the following: $query = SELECT legIDs FROM trip; $result = mysql_query($query) or
Please consider this example. (PHP) class Database{ private $result; private $conn; function query($sql){ $result
Please consider the following query: SELECT artist.id, COUNT(DISTINCT artist$styles.v_id) FROM artist LEFT JOIN artist$styles
Consider this query: SELECT F1,F2 FROM TABLE GROUP BY F1 Selecting F1 is valid,
please consider this code : 1-... 2-{ 3-... 4-SqlConnection cn=new SqlConnection(); 5-... 6-} if
please consider this code : 1)public static class MyClass 2){ 3) public static DateTime
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5
Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()
Please consider this site . I'm having trouble stretching the submenu list items in
Please Consider this scenario: We have a base class called clsMain : class clsMain

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.