PHP / MySQL - Querying based on a variable in SQL statements - help!

Associate
Joined
24 Jul 2004
Posts
1,580
Location
Preston, Lancs
Hello,

I have two tables, one is called Company, the other called Sites.

Company has the following:

Company ID (key)
Company name


Sites has the following:

Site id (key)
Company Name (matches the table above)
Site Name
Site URL


Its a very simple database, more of a test application currently. Each Company has many sub Sites.

All I want to do is have a Master table with the following info:

Company ID, Company Name, (number of sub) Sites


How can I run a query that will do this for me?

In psuedo code, basically its:

SELECT all
FROM both tables
WHERE company ID is the same in both
Then count the above and display a number in my table


Any help greatfully appreciated!
 
thank you, im a bit fried today after a bit of a mammoth coding session (2 hours straight, as a newb, it was intense).

Out of interest, what books did you guys read to learn about this stuff?

Thanks again! ill report back with results :)
 
Back
Top Bottom