开发者

I want to get all auto_incremented_id of a table in comma seperated format with one query is it possible?

开发者 https://www.devze.com 2023-03-22 09:53 出处:网络
Table structure is like given below idName 1Mukesh 2Shiwam 3deepak 4---开发者_运维百科--- I want in resultant Like 1,2,3,4 it is possible?Use GROUP_CONCAT():

Table structure is like given below

id           Name
1            Mukesh
2            Shiwam
3            deepak
4            ---开发者_运维百科---

I want in resultant Like 1,2,3,4 it is possible?


Use GROUP_CONCAT():

SELECT GROUP_CONCAT(id)
FROM table

It's as simple as it gets. Cularis' answer specifies using the , separator, but it's not actually necessary, unless you want spaces between the commas:

32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49

Which you didn't specify in your OP.


SELECT GROUP_CONCAT(id) FROM yTable

GROUP_CONCAT

Wth do you need this?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号