选择除了mysql中的一个字段之外的所有字段 [英] Selecting all fields except only one field in mysql

查看:2014
本文介绍了选择除了mysql中的一个字段之外的所有字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法来选择除数据库中的表格中的一个字段之外的所有字段。我知道我们可以在select查询中描述字段名称。例如:

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);

我正在使用mysql和zend框架...事先预先...

I am using mysql and zend framework..Thanks in advance...

推荐答案

你可以很容易做到这一点

you can do it easily like that

让你的字段是一个id = 5

lets say your field is an id = 5

然后

   select * from your_table where id !=5 

如果您的意思是

您不需要选择 column3

然后

   select column1,column2,column4 from tablename;

    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;

这篇关于选择除了mysql中的一个字段之外的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆