以字符串格式返回MySQL表中的所有列 [英] return all the columns in a MySQL table in a string format

查看:192
本文介绍了以字符串格式返回MySQL表中的所有列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以字符串格式返回MySQL表中的所有列?

Is there a way to return all the columns in a MySQL table in a string format?

我想返回这样的东西:

course_id, name, par, yds, mtrs

我知道如何在表(SHOW FIELDS FROM course;)中显示字段/列,但是这些字段/列是以表格格式返回的.

I am aware of how to show the fields/columns in a table (SHOW FIELDS FROM course;) however these are returned in a tabular format.

推荐答案

select group_concat(column_name separator ', ') 
from information_schema.columns 
where table_name = 'course' 
group by table_name

这篇关于以字符串格式返回MySQL表中的所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆