473,394 Members | 1,693 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,394 software developers and data experts.

inner join

i got two tables: tblCat, tblSubCat.
i need to get the list of all the category names (CatName), CatOrder from
tblCat when tblCat.CatID=tblSubCat.catPID and i need to know how many rows
do i got from each capPID.

this is what i used:
SELECT Count(tblSubCat.catPID) AS CountCatPID, tblCat.CatID, tblCat.CatName,
tblCat.CatOrder
FROM tblCat INNER JOIN tblSubCat ON tblCat.CatID = tblSubCat.catPID
GROUP BY tblCat.CatID, tblCat.CatName, tblCat.CatOrder
ORDER BY tblCat.CatOrder;

the problem is that there is one record in tblCat that don't got subCat so
it those not show in the list.
it give my back only the 3 categories and count good how many subs thay got
but it's not returning the category without the sub in tblSubCat.
what should i do to revieve the missing record too?
Nov 13 '05 #1
3 1507
how about a left join?

"Sagi" <sa**@schieber.net> wrote in message
news:42********@news.bezeqint.net...
i got two tables: tblCat, tblSubCat.
i need to get the list of all the category names (CatName), CatOrder from
tblCat when tblCat.CatID=tblSubCat.catPID and i need to know how many rows
do i got from each capPID.

this is what i used:
SELECT Count(tblSubCat.catPID) AS CountCatPID, tblCat.CatID,
tblCat.CatName, tblCat.CatOrder
FROM tblCat INNER JOIN tblSubCat ON tblCat.CatID = tblSubCat.catPID
GROUP BY tblCat.CatID, tblCat.CatName, tblCat.CatOrder
ORDER BY tblCat.CatOrder;

the problem is that there is one record in tblCat that don't got subCat so
it those not show in the list.
it give my back only the 3 categories and count good how many subs thay
got but it's not returning the category without the sub in tblSubCat.
what should i do to revieve the missing record too?

Nov 13 '05 #2
left join? with the same sql?

"Mike MacSween" <mi***************************@btinternet.com> wrote in
message news:42***********************@news.aaisp.net.uk.. .
how about a left join?

"Sagi" <sa**@schieber.net> wrote in message
news:42********@news.bezeqint.net...
i got two tables: tblCat, tblSubCat.
i need to get the list of all the category names (CatName), CatOrder from
tblCat when tblCat.CatID=tblSubCat.catPID and i need to know how many
rows do i got from each capPID.

this is what i used:
SELECT Count(tblSubCat.catPID) AS CountCatPID, tblCat.CatID,
tblCat.CatName, tblCat.CatOrder
FROM tblCat INNER JOIN tblSubCat ON tblCat.CatID = tblSubCat.catPID
GROUP BY tblCat.CatID, tblCat.CatName, tblCat.CatOrder
ORDER BY tblCat.CatOrder;

the problem is that there is one record in tblCat that don't got subCat
so it those not show in the list.
it give my back only the 3 categories and count good how many subs thay
got but it's not returning the category without the sub in tblSubCat.
what should i do to revieve the missing record too?


Nov 13 '05 #3
thank you so much, working great
"Mike MacSween" <mi***************************@btinternet.com> wrote in
message news:42***********************@news.aaisp.net.uk.. .
how about a left join?

"Sagi" <sa**@schieber.net> wrote in message
news:42********@news.bezeqint.net...
i got two tables: tblCat, tblSubCat.
i need to get the list of all the category names (CatName), CatOrder from
tblCat when tblCat.CatID=tblSubCat.catPID and i need to know how many
rows do i got from each capPID.

this is what i used:
SELECT Count(tblSubCat.catPID) AS CountCatPID, tblCat.CatID,
tblCat.CatName, tblCat.CatOrder
FROM tblCat INNER JOIN tblSubCat ON tblCat.CatID = tblSubCat.catPID
GROUP BY tblCat.CatID, tblCat.CatName, tblCat.CatOrder
ORDER BY tblCat.CatOrder;

the problem is that there is one record in tblCat that don't got subCat
so it those not show in the list.
it give my back only the 3 categories and count good how many subs thay
got but it's not returning the category without the sub in tblSubCat.
what should i do to revieve the missing record too?


Nov 13 '05 #4

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

Similar topics

3
by: Ike | last post by:
Oh I have a nasty query which runs incredibly slowly. I am running MySQL 4.0.20-standard. Thus, in trying to expedite the query, I am trying to set indexes in my tables. My query requires four...
3
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName,...
4
by: Nathan | last post by:
I have an application that uses an Access database to gather information on students' test scores. In the database there are three tables which are joined by one- to-many relationships: ...
6
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
52
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...
3
by: Zeff | last post by:
Hi all, I have a relational database, where all info is kept in separate tables and just the id's from those tables are stored in one central table (tblMaster)... I want to perform a query, so...
12
by: Chamnap | last post by:
Hello, everyone I have one question about the standard join and inner join, which one is faster and more reliable? Can you recommend me to use? Please, explain me... Thanks Chamnap
1
by: teneesh | last post by:
Here I have a code for a view that has been created by a developer on my team. I am trying to use the very same code to create a view for a different formid/quesid. But I cannot figure out how this...
2
by: MATTXtwo | last post by:
I have this store procedure to select data from table with join like this...SELECT tblPeribadi.Personel_No, tblPeribadi.Nama,tblCompany.Keterangan as Company_Code, tblPeribadi.Jawatan,...
4
by: AXESMI59 | last post by:
I created a query in the Access Query Builder that I modified to use with VBA Code so I could reuse it for any record I choose. The one that I created with the Access Query builder works beautifully...
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: 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?
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
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
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...
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...

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.