Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql procedure syntax error
    text
    copied!<p><br > I get an error by sending the following query (MYSQL 5.0):</p> <pre class="lang-sql prettyprint-override"><code> DELIMITER // CREATE PROCEDURE relationTable () BEGIN DECLARE articlecount int; DECLARE keywordcount int; DECLARE articlehits int; DECLARE ac int DEFAULT 0; DECLARE kc int; DECLARE articleid int; DECLARE word varchar(100); DECLARE word_id int; SET articlehits = 0; SET articlecount = (SELECT count(id) from articles); SET keywordcount = (SELECT count(id) from keywords); outerloop: WHILE (ac &lt; articlecount) DO SET kc = 0; SET articleid = (SELECT id from articles LIMIT 1 OFFSET ac); innerloop: WHILE (kc &lt; keywordcount) DO IF (articlehits &lt; 5) THEN SELECT keyword, id INTO word, word_id from keywords LIMIT 1 OFFSET kc; IF (0 &lt; (SELECT COUNT(id) from articles WHERE id=articleid AND CONCAT(title, " ",text) REGEXP word)) THEN INSERT INTO articles (id, articleID, keywordID, type) VALUES(NULL, articleid, word_id, 'type1'); SET articlehits = articlehits + 1; END IF; SET kc = kc + 1; ELSE SET kc = keywordcount; END IF; END WHILE innerloop; SET ac = ac + 1; END WHILE outerloop; END; // DELIMITER ; </code></pre> <p>This produces the following error: </p> <blockquote> <p>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1 OFFSET ac); innerloop: WHILE (kc &lt; keywordcount) DO TO word, word_id from' at line 15</p> </blockquote> <p>Any idea why this happens?</p> <p>(Wrote this to create a relation table between articles and keywords, to enable smart-links in article view.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload