Mysql选择哪里 [英] Mysql select where

查看:40
本文介绍了Mysql选择哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mysql select where value 90 and 45 but not 90 with type 1 here is my sample table

Mysql select where value 90 and 45 but not 90 with type 1 here is my sample table

value   |   type    |   status
90          1           0
90          1           1
90          0           0
90          0           1
45          1           0
45          1           1

我的代码没有得到想要的输出

My code didn't get the desired output

SELECT * FROM table WHERE type IN (1, 0) AND value != 90

所需的输出是:

value   |   type    |   status
90          0           0
90          0           1
45          1           0
45          1           1

推荐答案

您正在查看一个相当基本的复合条件 - 您想要all type=0"或all type=1 except when value=90",即表示为

You're looking at a fairly basic compound condition - you want "all type=0" or "all type=1 except when value=90", which would be expressed as

WHERE (type = 0) OR (type = 1 AND value != 90)

(基于您自己的查询),或

(based on your own query), or

WHERE (value = 45) OR (VALUE = 90 AND type != 1)

(基于你的第一句话.)

(based on your first sentence.)

这篇关于Mysql选择哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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