473,385 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Could someone please explain the process involved with Exists

The statament below does exactly what I want it to do but I don't understand
why?

In my mind the subquery produces a result set which is a subset of the
handset table which the initial part of the query is then applied to.
However, the 'select all from Sim where it doesn't exists' is the bit I
don't get where what doesn't exist? how is the comparison made? I haven't
specified a parameter etc..

Any help would be much appreciated.
SELECT *
FROM Sim
WHERE (((Exists (SELECT * FROM Handsets WHERE Sim.Number =
Handsets.Number))=False));
Sep 9 '06 #1
2 4838
blueyonder wrote:
The statament below does exactly what I want it to do but I don't
understand why?

In my mind the subquery produces a result set which is a subset of the
handset table which the initial part of the query is then applied to.
However, the 'select all from Sim where it doesn't exists' is the bit
I don't get where what doesn't exist? how is the comparison made? I
haven't specified a parameter etc..

Any help would be much appreciated.
SELECT *
FROM Sim
WHERE (((Exists (SELECT * FROM Handsets WHERE Sim.Number =
Handsets.Number))=False));
A query with an EXISTS clause simply reacts to whether the sub-query returns any
records. At least one record = "True" while zero records = "False". The outer
query does not "care" what the SQL statement of the inner query is. All it
cares about is whether it returns any records or not.

In your case the inner EXISTS will be true if the Sim number from the Sim table
can also be found in the Handsets table. Use of an EXISTS with "= False" is a
bit unusual. I would have used NOT EXISTS instead which would likely make more
sense to someone looking at the SQL.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Sep 9 '06 #2
Thank you Rick.

"Rick Brandt" <ri*********@hotmail.comwrote in message
news:9g****************@newssvr25.news.prodigy.net ...
blueyonder wrote:
>The statament below does exactly what I want it to do but I don't
understand why?

In my mind the subquery produces a result set which is a subset of the
handset table which the initial part of the query is then applied to.
However, the 'select all from Sim where it doesn't exists' is the bit
I don't get where what doesn't exist? how is the comparison made? I
haven't specified a parameter etc..

Any help would be much appreciated.
SELECT *
FROM Sim
WHERE (((Exists (SELECT * FROM Handsets WHERE Sim.Number =
Handsets.Number))=False));

A query with an EXISTS clause simply reacts to whether the sub-query
returns any records. At least one record = "True" while zero records =
"False". The outer query does not "care" what the SQL statement of the
inner query is. All it cares about is whether it returns any records or
not.

In your case the inner EXISTS will be true if the Sim number from the Sim
table can also be found in the Handsets table. Use of an EXISTS with "=
False" is a bit unusual. I would have used NOT EXISTS instead which would
likely make more sense to someone looking at the SQL.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Sep 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Chirico | last post by:
Hopefully this will help someone... Helpful Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Last Updated: Fri Apr 16 11:47:34 EDT 2004 The latest version of this...
8
by: Igor Raytsin | last post by:
Hello All, The following script is reproducing the problem assuming you have Northwind database on the server. Please note it gives you the error message on line 12. USE tempdb GO...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
5
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an...
5
by: Tom Vogel | last post by:
Creating a subfolder within my ASP.NET application folder fails with the above error, but only at my hosting provider. The command: Directory.CreateDirectory(path) Path is set to...
0
by: Shapper | last post by:
Hello, I have this code in Global.asax: Sub Session_Start(Sender As Object, E As EventArgs) Dim cookie As HttpCookie = Request.Cookies("MyCookie") If Not cookie Is Nothing Then...
1
by: mansa | last post by:
a) A company receives hundreds of orders every week through the mail. Explain carefully how BATCH- PROCESSING might be used. Describe the role of the BATCH TOTAL in this process. Explain how batch...
22
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is...
11
by: fniles | last post by:
One of our application uses VB6 and Access97 database. Another application uses VB.NET 2005. This morning for about 15 seconds when the application tries to read either a query or a table from the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.