fenway Posted January 26, 2007 Share Posted January 26, 2007 I doubt there is a solution to this problem, but I figured I'd share my frustrations. I know you can run SHOW COLUMNS to get the details of each column in a table, but for some reason, this is "output-only", and can't be used as a proper result set -- and I don't know why. AFAIK, there is no workaround to being able to "extract" such a list of fields in any way.If anyone has a brilliant workaround, I'd be duly impressed. Link to comment https://forums.phpfreaks.com/topic/35795-pre-mysql-5-column-name-retrieval-for-use-in-queries/ Share on other sites More sharing options...
hvle Posted January 26, 2007 Share Posted January 26, 2007 show columns do return a resultset[code]<?php $sql = "show columns from city"; $rs = mysql_query($sql); while ($values = mysql_fetch_assoc($rs)) { print_r($values); }?>[/code]output:[code]Array( [Field] => idn [Type] => int(10) unsigned [Null] => NO [Key] => PRI [Default] => [Extra] => auto_increment)Array( [Field] => name [Type] => varchar(45) [Null] => NO [Key] => [Default] => [Extra] => )Array( [Field] => state [Type] => varchar(45) [Null] => NO [Key] => [Default] => [Extra] => )Array( [Field] => path [Type] => varchar(128) [Null] => NO [Key] => [Default] => [Extra] => )Array( [Field] => link [Type] => varchar(128) [Null] => NO [Key] => [Default] => [Extra] => )[/code]is that what you wanted? it seems to work fine on my machine. Link to comment https://forums.phpfreaks.com/topic/35795-pre-mysql-5-column-name-retrieval-for-use-in-queries/#findComment-169662 Share on other sites More sharing options...
fenway Posted January 26, 2007 Author Share Posted January 26, 2007 Thanks, hvle, but I mean a "result set" in the SQL sense -- one that i can JOIN with other tables. Link to comment https://forums.phpfreaks.com/topic/35795-pre-mysql-5-column-name-retrieval-for-use-in-queries/#findComment-169768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.