2013-03-01 67 views
0

創建這個函數此給予錯誤:我嘗試在SQL

#1064 - 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 'TABLE where studentid=id); IF(@sid = 'INDIAN') THEN SET @data:= (s' at line 6

CREATE FUNCTION `dbu_application`.`atudentfee` (id int,code varchar(255)) 
    RETURNS int(11) 

    BEGIN 
    SET @sid := (SELECT TYPE FROM TABLE where studentid=id); 
    IF(@sid = 'INDIAN') THEN 
    SET @data:= (select data from table2 where progcode='code'); 
    ELSE set $data:=0; 
    END IF; 
    RETURN @data; 
    END$$ 

回答

1

TABLE是在MySQL的保留字。您不能將其用作實際表格的名稱,除非您將其用作反引號

SELECT TYPE FROM `TABLE` where studentid=id