homerUK
02-05-2007, 11:45 AM
hi,
I have 4 tables with many records to one table.
eg:
user_schemas
==========
schema_id
user_id
description
servicelines
==========
serviceline_id
schema_id
name
processes
=========
process_id
schema_id
name
I have got the following SQL working counting the number of servicelines for the one schema record. However, I am not sure how to count other stuff. I need one DB query to get the name of the "user_schema" and a count of all the records in the other tables.
here's what I have
SELECT
us.description,
us.user_id,
count(sl.ud_serviceline_id) AS sl_count
FROM user_schemas us
JOIN servicelines sl
ON us.schema_id = sl.schema_id
WHERE us.user_id = 3
GROUP BY sl.schema_id;
any help is much appreciated! :)
I have 4 tables with many records to one table.
eg:
user_schemas
==========
schema_id
user_id
description
servicelines
==========
serviceline_id
schema_id
name
processes
=========
process_id
schema_id
name
I have got the following SQL working counting the number of servicelines for the one schema record. However, I am not sure how to count other stuff. I need one DB query to get the name of the "user_schema" and a count of all the records in the other tables.
here's what I have
SELECT
us.description,
us.user_id,
count(sl.ud_serviceline_id) AS sl_count
FROM user_schemas us
JOIN servicelines sl
ON us.schema_id = sl.schema_id
WHERE us.user_id = 3
GROUP BY sl.schema_id;
any help is much appreciated! :)