I need to figure out how to update a column NumMembers with the current count of members.
I know I use this
UPDATE groups
SET NumMembers =
but how do I insert my count code below into this?
I have a query that counts the number of members in a table
first I create this view
create view myview
as
SELECT lname, fname, gname
FROM groups g, members m
WHERE g.gid=m.groupid
then
SELECT x.gname, count(*) as Total
FROM myview x, myview y
WHERE x.gname=y.gname and x.lname=y.lname
GROUP BY x.gname