Page 1 of 1
Any easy way to select only columns with values?
Posted: Fri Sep 08, 2006 2:38 am
by Ward
I have a huge data table which stores CSV report data for users. A user can view his report, which currently selects all records tied to his userID. However, not all of the columns are even used, only around 5 or 10, depending on the CSV format which was uploaded. Is there any easy way to filter out the null columns in a select statement? The only other option is to do it through PHP, which will be more work.
Posted: Fri Sep 08, 2006 3:14 am
by Christopher
Is this in a database or in a CSV text file? I am guessing a database. You can specify the columns that you want using the "SELECT col1,col2 FROM table" syntax. But you can't say to only provide data from non-Null columns. Besides, there is no data to retrieve so the Null columns should not increase the amount of data transfered much.
Posted: Fri Sep 08, 2006 10:17 am
by Ward
Its coming from a MySQL database. The data is put into a big 2-dimensional array, which is passed to a php datagrid control. I can only "hide" a column if the entire column has no values.