I am very new to SQL scripts and cannot figure out how to make it specific for each loop. I need to do something like this:
I have tables Sitesand SiteCrawls.
Sites
SiteCrawls
Basically, for each site I need to create a new one SiteCrawl, and the column SiteCrawl Site_IDwill be equal to this site identifier.
SiteCrawl
Site_ID
How can i do this?
insert SiteCrawl ( Site_ID ) select s.Site_ID from Site as s where s.Site_ID not in (select Site_ID from SiteCrawl)
insert into site_crawl (site_id) values (select site_id from site);
, : / SQL, . , : SQL- - , a . , site_crawl site_id . , , , , , :)
: , sql .
, SQL - !
SQL . .
-
insert into SiteCrawl (Site_Id) select Id from Sites
insert into SiteCrawls (SiteID) select SiteID from Sites
CREATE TRIGGER tg AFTER INSERT ON `Sites` FOR EACH ROW BEGIN insert into SiteCrawls(Site_ID) values (NEW.id); END ;