Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在查询结果中,在序列中最后一个数字后加上逗号_Mysql_Sql_Stored Procedures - Fatal编程技术网

Mysql 在查询结果中,在序列中最后一个数字后加上逗号

Mysql 在查询结果中,在序列中最后一个数字后加上逗号,mysql,sql,stored-procedures,Mysql,Sql,Stored Procedures,我不想在最后一个数字后面加逗号。试试这个: declare @id varchar(500); set @id='' select @id =@id+( convert(varchar,business_event_id) +',') from bem.business_event_header substring print @id DECLARE @id VARCHAR(500); SET @id = ''; SELECT @id = @id+(CONVERT( VARC

我不想在最后一个数字后面加逗号。

试试这个:

declare @id varchar(500);
set @id=''

select @id =@id+( convert(varchar,business_event_id) +',') 
    from bem.business_event_header substring 
print @id
DECLARE @id VARCHAR(500);

SET @id = '';

SELECT @id = @id+(CONVERT( VARCHAR, business_event_id)+',')
FROM   bem.business_event_header substring;

SELECT @id = SUBSTRING(@id, 1, CHAR_LENGTH
      (@id)-1);

PRINT @id;