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 ' CASE WHEN acc.ws_type=1 THEN N'街批' WHEN acc.ws_type=2 THEN N' at line 26
时间: 2023-10-14 18:03:02 浏览: 40
I'm sorry, but I am an AI language model and I do not have enough context to provide a helpful answer. It seems that you are encountering an error related to SQL syntax. Can you provide more details about the SQL query you are trying to execute and the database you are using? Additionally, have you checked the syntax of your query against the documentation for your specific version of MySQL?
相关问题
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 'FROM * `EMP`' at line 1
The error message indicates that there is a syntax error in your SQL query. In this case, it seems that you are using the `FROM` keyword incorrectly. The correct syntax for a basic `SELECT` statement is:
```
SELECT column1, column2, ...
FROM table_name
```
Make sure you specify the table name after the `FROM` keyword, not an asterisk (*). It should be something like:
```
SELECT *
FROM EMP;
```
If you still encounter the error, please provide more information about your query or the table structure so that I can assist you further.
ERROR 1064 (42000) at line 6: 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 '; when sum(sjfk)>=5000 and sum(sjfk)<10000 then 'vip'; ' at line 6
这个错误可能是因为在 `return` 语句中出现了分号,而导致 MySQL 解析错误。请将 `return` 语句修改为以下形式:
```sql
return level;
```
也就是去掉分号,只返回变量 `level` 的值即可。这个问题在代码中出现在第 6 行附近。修改后的代码如下:
```sql
use sale;
delimiter $$
create function gkjb(nf int,xm varchar(10)) Returns varchar(10)
begin
declare level varchar(30) charset utf8;
select (case
when sum(sjfk)>=10000 then '超级vip'
when sum(sjfk)>=5000 and sum(sjfk)<10000 then 'vip'
when sum(sjfk)>=0 and sum(sjfk)<5000 then '一般会员'
else '非会员'
end) into level
from gk join xsd on gk.hyh=xsd.hyh
where name=xm and DATE_FORMAT(xsrq,'%Y')=nf;
return level;
end
$$
delimiter ;
select name as 姓名,gkjb(2015,name) as 级别 from gk;
```
请注意,修改后的代码中,`return` 语句的末尾没有分号。