Many-to-many - 2


SELECT _ FROM = SELECT COUNT (*) FROM WHERE _ = ._

SELECT _ FROM <= SELECT SUM () FROM WHERE _ = ._

, : , , , , , . - , . , . , , . , , , .

ON INSERT TO UPDATE SET NEW (_) = OLD (_) + 1 WHERE _ = ._

ON DELETE FROM UPDATE SET NEW (_) = OLD (_) - 1 WHERE _ = ._

. - . . , . , , ,

(_, _)

ON INSERT, DELETE FROM IF EXISTS (SELECT * FROM WHERE _ = TODAY) UPDATE SET NEW (_) = OLD (_) + 1 WHERE _ = TODAY ELSE INSERT INTO (TODAY, 1)