Home:ALL Converter>Mysql select query to omit specific fileds

Mysql select query to omit specific fileds

Ask Time:2015-04-17T14:25:28         Author:Amit Shah

Json Formatter

we can create mysql query to select all fields, we can create mysql query to select necessary fields.

select * to select all fields

select fieldname to select specific fields, but is there any way to select all fields except 1 or 2

Thanks Amit

Author:Amit Shah,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29691832/mysql-select-query-to-omit-specific-fileds
Sudip Gautam :

This should help \n\nSET @query = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<OMITTED COLUMN>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<TABLE NAME>' ), ' FROM <TABLE NAME>');\n\nprepare statement from @query;\nexecute statement\n",
2015-04-17T06:45:10
Abhik Chakraborty :

In case of select specific fields you have no way but to select the specific columns as\n\nselect col1, col2, col3 ... from table_name \n\n\nLeave the columns which you do not want to select and add those you want to select.",
2015-04-17T06:26:45
yy