Question: I want to execute a SELECT query but I don't how many columns to select.

Like:

```
select name, family from persons;

```

How can I know which columns to select?

"I am currently designing a site for the execute query by users.
So when the user executes this query, I won't know which columns selected.
But when I want to show the results and draw a table for the user I should know which columns selected."

Answer: 
If I understand what you are asking, you probably want to use MySQLIi and the the fetch\_fields method on the result set:

<http://us3.php.net/manual/en/mysqli-result.fetch-fields.php>

See the examples on that page.
use `DESC table` or

**Example**

```
SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name='your_table';

```

**output**

```
 column1,column2,column3

```