Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Select all columns except one in MySQL?

SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');

PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Select #columns
ADD COMMENT
Topic
Name
4+6 =