mysql 字段,选择除了mysql中的一个字段之外的所有字段

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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值