asp.net - How to count the number of ROWS in SQL table -
i have 2 tables. first table (class) table in there classes student can choose, , last column(numberofregistration) number of registration per class. here first table:
idclass int; name varchar(50); date varchar(50); state bit; description nvarchar(50); numberofregistration int
second table (registration) registration:
idregistration int; dateofregistration date; name varchar(50); lastname varchar(50); city nvarchar(50); adress nvarchar(50); postalnumber int; idclass int - foreign key, references idclass class table ;
does have idea how number of registration per class in table registration , , write data last column(numberofregistration) in table class.
thank you
try this:
update c set numberofregistration = count(0) class c left join registration r on r.idclass = c.idclass group r.idclass;
Comments
Post a Comment