0

I want to display the records from a table, except a few columns. The table has 94 columns in it and I want to view all of them except 5. Is that possible? If so, please let me know how?

I know I could select the required columns by specifying them. But I want to omit 5 columns out of 94. It is always better to omit 5 than specifying 89?

I googled but I did not get any idea to do this. So I just want to give last try here!

Leigh
  • 28,765
  • 10
  • 55
  • 103
Chella
  • 1,561
  • 4
  • 23
  • 42

1 Answers1

0
$Database_Name="database_example";
$table_example="table_example";
$result = mysql_query("select column_name from information_schema.columns where table_schema = '$Database_Name' and table_name='$table_example' AND column_name NOT IN ('Col89', 'col90','col91','col92', 'col93','col94')");

if (!$result) { 
    die('Invalid request : ' . mysql_error());
}

$SQL="SELECT ";
while ($row = mysql_fetch_row($result)) {   
    foreach($row as $ColonneName)
        $SQL.=$ColonneName.",";
}   

$SQL=rtrim($SQL, ",")." FROM _table_example";

    echo $SQL;
Houari
  • 5,326
  • 3
  • 31
  • 54
  • It just display columns,But I want to display all the records inside a table – Chella Dec 11 '12 at 10:31
  • GOod work..I appreciate..! But I asked you a query, but you have given me PHP code..Any way Thank you HOurai..! – Chella Dec 12 '12 at 04:32
  • You can't do it only with the `SQL`, you have to generate your required SQL with `PHP`(Without writing the full column names manually). But i don't understand why someone votedown my post :( – Houari Dec 12 '12 at 09:56