I have 10 fields in my table but i need 8 fields when i select , i dont want to specify select 1,2,3,4,5,6,7,8 from........
,
Any easy way to get the 8 fields (Other hand i dont want to select primary,unique key fields)
views:
22answers:
1
+1
A:
see the answer in this :
http://stackoverflow.com/questions/9122/select-all-columns-except-one-in-mysql
Actually there is a way, you need to have permissions of course for doing this ...
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_delete>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
Replacing <table>, <database> and <columns_to_delete>
Haim Evgi
2010-10-06 06:15:22