473,750 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Subquery joins on same table

9 New Member
Everyone,

I am just starting my work with subqueries and I am a little lost on how to handle the syntax on one part.

I have a query that will contain some subqueries for the purpose of counting the records in three different tables.

I understand how to create the subqueries for the most part but I am unsure how to set-up the join since all 3 subqueries will need to join back to the same table that also has to be joined to one other table not in any of the subqueries.

Basically each table (lets say tbl1, tbl2, and tbl3) has the field "Item" that will need to be counted and joined to tblItems.Item.

How do I got about setting up the syntax on those joins? I know how to make them individually but not all the in the same query.

An example of what one of the queries looks like follows:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblItems.Item, Count(Q.Item) AS KanbanInHold
  2. FROM [SELECT tblKanbanInHold.Item
  3. FROM tblKanbanInHold INNER JOIN tblItems ON tblKanbanInHold.Item = tblItems.Item]. AS Q INNER JOIN tblItems ON Q.Item = tblItems.Item
  4. GROUP BY tblItems.Item;
Thanks
Aug 25 '08 #1
1 2581
aas4mis
97 New Member
The inner join syntax will only join items that are matching. If you have different items your joins are doing nothing. I don't have access in front of me but I believe you want a UNION or possibly a LEFT join.
Sep 20 '08 #2

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

Similar topics

3
70117
by: Falco Vermeer | last post by:
Hi, I tried to use the following query to update a value in one table with a value from another table: UPDATE tbl1 SET col1 = tbl2.col2 FROM tbl1, tbl2 WHERE tbl1. = tbl2.
4
1261
by: Bruce D | last post by:
I have this simple subquery...and I get an error when I try to run it?? SELECT ZipID FROM testzip WHERE ZipID <> ( SELECT ZipID FROM Zip ) any ideas?
7
9225
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into a table (c) re-queries another table using a subquery which references the inserted table (correlated or not)
8
19600
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 couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
1
2936
by: Phoenix_ver10 | last post by:
I have a mailing list with multiple names going to the same addresses. I need one address with all the names for that address on it. I checked out the example on microsoft's site, but A: It doesn't work (error that there is an extra parenthise (sp?) ) and B: Will only let in two names for each record. If there are three, the middle on is deleted. Or to make things simpler, if nothing else, I'd like to add a field in the table that shows...
52
6341
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
1
4168
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only allows me to filter based on variables in a single table. I would like to have a search form where I can select multiple variables (from various linked tables) to filter by, and return results based on this multi-table filter. Allen Browne...
2
3169
by: beargrease | last post by:
I'm kind of comfortable with basic joins, but a current project requires a complex query of many tables. The GROUP_CONCAT(DISTINCT ...) function has been very useful as returning my values as comma delimited values when joining multiple tables. I have one table called 'floorplans' which has two fields (floorplan_jpg & floorplan_pdf), I'd like each of these fields to return arrays of the same length (they have the same # of values in the data...
1
4112
by: drahmani | last post by:
Can anyone tell me how to do this in Oracle? This is not the exact query but I wanted to simplify it a little. The problem I see is that the WHERE clause depends on the join which I cannot do in Oracle. ------ A update table1 t1 set t1.pdesc=t2.pdesc, t1.pcost=t3.pcost from table1 t1 left outer join table2 t2 on t1.name=t2.name left outer join table3 t3 on t2.product=t3.product where t1.site='MD' and t1.pdesc...
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.