Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I make a query that give me zero rows (ok: no row meets my select).

Is there a way to fetch only the attribute names, also if there is not any row with data?

$row_number = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
{
     // Fetch just two field names, only the first row fetched
     if ($row_number==0) {
           $desc = $row["DESCRIPTION"];
           $unit = $row["UNIT"];  
    }
// ....
}   

Thank you in advance

share|improve this question
add comment

1 Answer

If i understood your question correctly :

You can use the metadata provided by mysql in information_schema.
There in COLUMNS table you can find out the name , type etc of the columns that you need.

share|improve this answer
 
I wasn't clear, my apologies: I was referring to the contents of two fields always present in a table. My mistake was that I tried to select it from a join query with this table (so it couldn't be fetched if Join give no results). I worked around by adding (before) a select query on that table in order to fetch just these values then make a second query (join) that could give o not rows. –  user2452426 Jun 10 at 20:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.