473,405 Members | 2,373 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,405 software developers and data experts.

subquery question

n8kindt
221 100+
so i've read up a little bit about subqueries. honestly, i do not see the point. from what i get out of it, a query with a subquery is very similar (if not identical?) to a query using another query as its data source. am i right on this one?

thank you for your replies.
nate
Apr 15 '08 #1
5 2038
Delerna
1,134 Expert 1GB
Yes you are perfectly correct, A query that has a subquery is exactly like a query joined to another query.

The attraction of subqueries, for me anyway, is that you finish up with less queries in the list queries tab. When a query is being written solely to massage date for use by another query and the query that is doing the massaging will never be used by anything else, then it makes sense to write the massaging query as a subquery within the main query. That way I finish up with 1 query instead of 2 or 3 . It may seem a minor point but a large project can have hundreds of queries many of which performing data massaging for single queries.

Using subqueries eliminates those which makes it easier for me to come back to the project 1 year after it was finished and still be able to find my way around.

By the way, for the very same reason stated above I do the following
If a form needs to run an update or a delete query I use DAO or ADO to execute a query string in the VBA code section of the form rather than have query in the querydefs. In the forms code the purpose of the query is more obvious than if it was in the queries tab and there is 1 or more less queries hiding amongst hundreds.

Anyway, those are my reasons.
Apr 15 '08 #2
n8kindt
221 100+
thanks, Delerna. yeah, i kind of figured that was the case. i can see how it would be less messy with fewer outwardly visible queries. it would guess that there is no performance-related penalties for using either option. i was just wondering this b/c i have a database that is in its final stages and i was considering stripping it down and switching from a smorgasboard of queries to subqueries. i don't think the end justifies the means in this case. instead, i will just take extra time in organizing the sidebar listings into clear categories.
Apr 16 '08 #3
FishVal
2,653 Expert 2GB
There is an article in HowTos section describing various ways subqueries may be used.
Apr 16 '08 #4
n8kindt
221 100+
There is an article in HowTos section describing various ways subqueries may be used.
fish, i have no idea how your replies seem to fly under my radar but i just noticed THIS reply too! as always, thank you for your reply. anyways, i found something interesting after downloading the sample file in the howto section u pointed me to--it got to the root of my "query" (ha). u may already know this but...

i opened the sample db on my computer at home (which uses 2003) and realized i couldn't look at the subqueries in design view. the computer i use at work is access 2007. i created this thread b/c when i made a subquery in 2007, i still was able to view the query in design view (with the exception of the subquery field itself--it was displayed in SQL language as an expression). so u can imagine why i wondered why subqueries where such a big deal. in design view, it looks nearly identical to a query using another query field as a reference.

if u guys have no idea what i'm talking about and are interested, i will post a screenshot of what i'm talking about when i get back to work tomorrow.
Apr 24 '08 #5
FishVal
2,653 Expert 2GB
Hi, Nathan.

I use Access 2003 and in design view it represents subquery in FROM clause like table/query even if subquery itself could not be represented in design view (e.g. joins not based on fields equality). This makes evidence that Access just looks for available fields in subquery.

Anyway, I would not worry about it as soon as it could be executed, no matter the query builder is unable to bring a picture. Not an outstanding case. ;)

Regards,
Fish
Apr 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: David Berry | last post by:
Hi All. I have a SQL Statement on an ASP page that only returns 4 records. When I run it in SQL Server or Query Analyzer it runs in less than a second. When I run it from my ASP page I get: ...
4
by: Hans | last post by:
Hello group, I have a table with the next contents. It lists data about : Who sent what kind of message at what time. For the Level column: The highest level is Critical, the middle is Warning,...
1
by: Aaron C | last post by:
I have the following code: SELECT DISTINCT StudentID FROM Students WHERE StudentID != ANY (SELECT StudentID FROM Voted) It seems like it's worded correctly, but I keep getting an error...
3
by: Maarten | last post by:
I've the following problem: Table1 serie | dir Table2 serie | user I am making a webpage in php to administrate the values in the db. What I want is that I select all series...
1
by: Dennis Haney | last post by:
Hi I was looking at pull_up_subqueries (backend/optimizer/prep/prepjointree.c 135) and I was wondering why the recursive optimization is only done on subqueries that can be optimized. As in,...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
3
by: laurentc via AccessMonster.com | last post by:
Hi. I have an issue with my Access project. I have rather big tables of data (about 11 000 rows). These tables are historical product quotations, so they are very simple : - MyDate...
3
by: Michel Esber | last post by:
Hi all, Db2 v8 FP15 LUW . create table T (ID varchar (24), ABC timestamp) There is an index for (ID, ABC), allowing reverse Scans. My application needs to determine MIN and MAX(ABC) for a...
2
by: HeavenCore | last post by:
Hello Everyone, i have a rather chunky Query: SELECT top 100 percent EMDET.DET_NUMBERA, EMDET.DET_G1_NAME1A, EMDET.DET_SURNAMEA, EMDET.DET_BIR_DATED, EMDET.DET_SFT_DATED, EMPOS.POS_PDT_GRDA,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.