I want to get all auto_incremented_id of a table in comma seperated format with one query is it possible?
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?
精彩评论