I want to know is there a way to select all fields except one field from a table in my database.I know we can describe the field names in the select query.For example:
select fieldname1,fieldname2,fieldname3,fieldname4 from tablename;
But my question is, is there any way to do it in simple way... Like this
select * from tablename except(fieldname);
I am using mysql and zend framework..Thanks in advance...
解决方案
you can do it easily like that
lets say your field is an id = 5
then
select * from your_table where id !=5
and if you mean columns
lets say you dont want select column3
then
select column1,column2,column4 from tablename;
if you have many columns
SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), ',', '')
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '
PREPARE stmt1 FROM @sql;
EXECUTE stmt1;