-1

I am having a table that contains 61 columns.

In the select statement I want to fetch all the columns except two of them.

How can I do it?

Here is the code that fetches data from table:

function hotelfeature($id)
{
    global $conn;
    $selFeature = "select * from hotelpropertyoptioninfo where Hotel_id = " .$id;
    $resultFeature = mysql_query($selFeature,$conn);
    $rowFeature = mysql_fetch_assoc($resultFeature);
    return $rowFeature;
}
nowox
  • 25,978
  • 39
  • 143
  • 293

1 Answers1

0
SET @SQL = CONCAT('SELECT ', (SELECT GROUP_CONCAT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = '<table>' AND COLUMN_NAME NOT IN ('field1','Field2')), 
' FROM <table>');
PREPARE stmt1 FROM @SQL;
EXECUTE stmt1;
HashSu
  • 1,507
  • 1
  • 13
  • 13