473,504 Members | 13,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Count on 'Joined' tables

Hi there

I have two tables, pages and sections, of which pages are a subset of
sections. I'm listing out the sections in a list and want to include a
COUNT of how many pages each section has within it.

Pages contain a 'sectionid' field to join it to the 'id' in the seciton
table but im unsure how to join, and group to get a count of the
number of pages in each section (i.e. in each result row)

If anyone can point me in the right direction, id be eternally greatful
:-)

Jul 12 '06 #1
2 1623

danny_m wrote:
Hi there

I have two tables, pages and sections, of which pages are a subset of
sections. I'm listing out the sections in a list and want to include a
COUNT of how many pages each section has within it.

Pages contain a 'sectionid' field to join it to the 'id' in the seciton
table but im unsure how to join, and group to get a count of the
number of pages in each section (i.e. in each result row)

If anyone can point me in the right direction, id be eternally greatful
:-)
not sure if this is what you need exactly, but if your running two
separate mysql queries on the same page just:

$totalrows = mysql_num_rows($query1)+mysql_num_rows($query2);

Flamer.

Jul 12 '06 #2
flamer di******@hotmail.com wrote:
danny_m wrote:
Hi there

I have two tables, pages and sections, of which pages are a subset of
sections. I'm listing out the sections in a list and want to include a
COUNT of how many pages each section has within it.

Pages contain a 'sectionid' field to join it to the 'id' in the seciton
table but im unsure how to join, and group to get a count of the
number of pages in each section (i.e. in each result row)

If anyone can point me in the right direction, id be eternally greatful
:-)

not sure if this is what you need exactly, but if your running two
separate mysql queries on the same page just:

$totalrows = mysql_num_rows($query1)+mysql_num_rows($query2);

Flamer.
the syntax will be along the lines of:

select s.section, sum(p.page) from sections s
left join pages on p.section_id = l.section_id
group by section_id

Jul 12 '06 #3

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

Similar topics

3
23994
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
2
23874
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
1
2073
by: Michael | last post by:
I have a query that uses two joined tables. The query contains data. I would like to pull in a data drom another table but when I add that table to the query design and make the join,the existing...
2
4256
by: Paula | last post by:
A query contains the fields CustomerID, CustomerName, OrderID, OrderDate and ItemID. The query is based on a customers table, orders table, and order details table. The orders table has a foreign...
1
1690
by: Carl B Davis | last post by:
Help please!!! I am an intermediate access user that is getting my bottom kicked by what seems an easy problem to fix. I maintain an employee database at work. I have set up a query from two tables...
1
3999
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
1
3173
by: Ersin Gençtürk | last post by:
hi , I have 2 tables , tUser and tUserRole and I have a query like : select * from tUser inner join tUserRole on tUserRole.UserId=tUser.UserId where tUser.UserId=1 this will return a user...
4
23867
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: ...
2
3358
by: sbuelter | last post by:
Struggleing with an issue....let me know if anyone can help: I have a continuous form that simply displays the results of a table that contains product information. I would like to include on...
0
7213
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
7098
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
7366
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...
1
7017
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
7471
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
5610
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
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 ...

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.