Gaurav Srivastava
Gaurav Srivastava

Reputation: 151

get column name from mysql

I want to know how can we get the column name from the table where data=this is the condition.

Suppose I want to get the column name where data="this" where this is the data present in that column

      username

      ram
      sham
      gaurav

here username is the column name and i want to get this name on the basis of ram,sham etc

Upvotes: 0

Views: 799

Answers (2)

Ahmed Abada
Ahmed Abada

Reputation: 101

 $dataurl=mysql_fetch_field($query,$indexr_numberfields_in_one_row);

 $valueurl=$arrayurl[$dataurl->name];

 $col5=$dataurl->name;

Upvotes: 1

Saurabh Gokhale
Saurabh Gokhale

Reputation: 46425

SHOW COLUMNS displays information about the columns in a given table. The LIKE clause, if present, indicates which column names to match. The WHERE clause can be given to select rows using more general conditions.

Here's the syntax :

SHOW [FULL] COLUMNS {FROM | IN} tbl_name [{FROM | IN} db_name]
    [LIKE 'pattern' | WHERE expr]

Upvotes: 1

Related Questions