DELIMITER $
CREATE PROCEDURE create_cit_table()
BEGIN
SET @totalid = (SELECT COUNT(id) FROM entity.name_search);
SET @i = 1;
WHILE @i <= @totalid DO
SET @name = (SELECT name_friendly FROM entity.name_search WHERE id = @i);
INSERT INTO tls_name_frnd_citations
(SELECT p1.name_friendly, a.publn_ops, COUNT(distinct a2.appln_id) as cit_count FROM tls201_appln a
INNER JOIN tls211_pat_publn b1 ON b1.appln_id = a.appln_id
INNER JOIN tls212_citation c ON c.cited_pat_publn_id = b1.pat_publn_id
INNER JOIN tls211_pat_publn b2 ON b2.pat_publn_id = c.pat_publn_id
INNER JOIN tls201_appln a2 ON a2.appln_id = b2.appln_id
INNER JOIN tls207_pers_appln pa1 ON pa1.appln_id = a.appln_id
INNER JOIN entity.combined p1 ON p1.person_id = pa1.person_id
INNER JOIN tls207_pers_appln pa2 ON pa2.appln_id = b2.appln_id
INNER JOIN entity.combined p2 ON p2.person_id = pa2.person_id
WHERE p1.name_friendly LIKE CONCAT(@name)
AND p2.name_friendly NOT LIKE CONCAT(@name)
GROUP BY a.publn_ops, p1.name_friendly
ORDER BY cit_count DESC
LIMIT 20;);
SET @i = @i + 1;
END WHILE;
END$
DELIMITER ;
上面的SQL程序在SET @totalid = (SELECT COUNT(' at line 1
语法上给我错误语法错误我似乎找不到错误,是否还有其他方法可以在MYSQL中分配变量