MySQL query to get column names?

前端 未结 21 2158
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 01:56

I\'d like to get all of a mysql table\'s col names into an array in php?

Is there a query for this?

21条回答
  •  你的背包
    2020-11-22 02:50

    if you use php, use this gist.

    it can get select fields full info with no result,and all custom fields such as:

    SELECT a.name aname, b.name bname, b.* 
    FROM table1 a LEFT JOIN table2 b
    ON a.id = b.pid;
    

    if above sql return no data,will also get the field names aname, bname, b's other field name

    just two line:

    $query_info = mysqli_query($link, $data_source);
    $fetch_fields_result = $query_info->fetch_fields();
    

提交回复
热议问题