Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MYSQL在另一个字段中设置值时隐藏字段数据_Mysql_Select_If Statement_Where_Data Representation - Fatal编程技术网

MYSQL在另一个字段中设置值时隐藏字段数据

MYSQL在另一个字段中设置值时隐藏字段数据,mysql,select,if-statement,where,data-representation,Mysql,Select,If Statement,Where,Data Representation,有这样一张桌子: art. type price a b 1 a c 2 是否可以通过选择将筛选内容显示为: art. type price a b a c 2 因此,如果类型为“b”,则不显示价格数据 select art, type, price from x where type="b" hide price 这种逻辑最适合应用程序的表示层,而不是数据库

有这样一张桌子:

art.    type    price
a        b       1
a        c       2
是否可以通过选择将筛选内容显示为:

art.    type    price
a        b       
a        c       2
因此,如果类型为“b”,则不显示价格数据

select art, type, price from x 
where type="b" hide price

这种逻辑最适合应用程序的表示层,而不是数据库层。但是,仍然可以使用MySQL的函数或其表达式,例如:

SELECT art, type, IF(type='b',NULL,price) price FROM x;

请在上查看。

决定是否隐藏字段的条件是什么?