I have a database table called stories. It only has one row---story.
How do I return all the stories in a, concatenated in a single string variable?
I thought it would be merely
$sql = mysql_query("select * from stories");
Incorrect?
You could use GROUP_CONCAT() :
SELECT GROUP_CONCAT(story) FROM stories;
This will return a concatenated string with each story separated by an ',' character.
If you would like to remove the separator you can use the following syntax:
SELECT GROUP_CONCAT(story SEPARATOR '') FROM stories;
Try this:
select GROUP_CONCAT(story_column) as stories from stories
Here story_column is name of column where stories are saved in table.
It will give you all stories in a single string with concatenating.
我不明白您的问题,但这可能会对您有所帮助。
SELECT CONCAT(`col1`, ' ', `col2`,' ',`col3`) FROM `table`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.