我寫的代碼爲mysql存儲過程它顯示語法錯誤我不知道我做了什麼錯誤。任何人都請幫助我。mysql語法錯誤,同時設置存儲過程參數
DELIMITER $$
DROP PROCEDURE IF EXISTS `aad_adr`.` PROCEDURE MonthlySalesReport(fromdate DATE,todate DATE)` $$
CREATE PROCEDURE `aad_adr`.` PROCEDURE MonthlySalesReport(fromdate DATE,todate DATE)`()
BEGIN
Declare fd DATE;
Declare ed DATE;
SET fd=fromdate;
SET ed=todate;
WHILE DATE(fd)<=DATE(ed)DO
select bill_master.bill_no,DATE_FORMAT(bill_master.bill_date, '%y/%m/%d') AS 'formatted_date',transaction.product_id,transaction.tax_amount,transaction.amount,transaction.amount-transaction.tax_amount as 'without_tax ',product_master.Product_name,product_master.vat from bill_master inner join transaction on bill_master.bill_no=transaction.bill_no inner join product_master on transaction.product_id=product_master.product_id where vat='14.50' and DATE_FORMAT(bill_master.bill_date, '%y/%m/%d') fd;
SET fd=DATE_ADD(fd,INTERVAL 1 DAY);
END WHILE;
END $$
DELIMITER;
錯誤:
Script line: 4 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 'fd;
SET fd=DATE_ADD(fd,INTERVAL 1 DAY);
END WHILE;
END' at line 8
刪除FD where子句中... –
謝謝現在它的執行 –
如果你有這個帖子上的解決方案,那麼你應該遵循此http://元。 stackexchange.com/questions/5234/how-does-accepting-an-answer-work –