我需要使用group_concat来构建一个用逗号分隔的值的列表,但是我需要在单引号内将这些值引起来。这该怎么做?我写的查询对我不起作用 实际上,我在这样的列中有值:
userid (column)
1) 1,2
2) 3,4
Query 1:
SELECT GROUP_CONCAT( DISTINCT CONCAT('\'', user_id, '\'') ) as listed_id
Query 2:
SELECT GROUP_CONCAT( DISTINCT CONCAT('''', user_id, '''') ) as listed_id
Expected out put:
'1','2','3','4'
But I am getting values like this
'1,2,3,4'
答案 0 :(得分:2)
尝试一下,在我的情况下,它工作得很好:
void convert(char src[], char dest[]) {
int i, isVowel, first_pos;
int len = strlen(src);
int count = 0;
char first = 0;
for (i = 0; i <= len; i++) {
while (src[i] && !isspace(src[i])) {
if (first == 0) {
first = src[i];
first_pos = i;
}
isVowel = first == 'a' || first == 'e' || first == 'i' || first == 'o' || first == 'u';
if (isVowel == 1) {
dest[count++] = src[i];
}
else if (i != first_pos) {
dest[count++] = src[i];
}
i++;
}
if (isVowel == 0) {
dest[count++] = first;
}
dest[count++] = ' ';
first = 0;
}
dest[count++] = '\0';
}