简体   繁体   中英

How to NOT select a column for MySQL table, does it make faster query

I need to make a MySQL query where I don't want to select a column named description. Is there an easy way to specifically say to NOT select the column.

Example: I want to SELECT all but the description column . Can this be done or I have to write each one I need to pick instead?

id| Serverid | date_added | description ...
 1        yes   12.03.09     bad engine
 3        yes   12.04.09     ok engine
 2        no    12.05.09     ok engine
 4        yes   12.06.09     bad engine



$cars = lib::$db->GetAll("SELECT SQL_CALC_FOUND_ROWS
                c.*,
            FROM cars AS c
            ORDER c.date_added DESC
            LIMIT 10);
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN1), '<Col To Omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<TableName>' AND TABLE_SCHEMA = '<DBName>'), ' FROM <TableName>');

PREPARE stmt1 FROM @sql;
EXECUTE stmt1;

No, there is no sane way to do that except listing all fields manually, like

SELECT id, Serverid, date_added FROM table

On a side note, with any sensible setup, there would be no difference in performance if you do SELECT *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM