MySQL选择哪个列不是空的。
16lz
2021-01-22
In MySQL, can I select columns only where something exists?
在MySQL中,我可以只在存在的地方选择列吗?
For example, I have the following query:
例如,我有以下查询:
select phone, phone2
from jewishyellow.users
where phone like '813%'
and phone2
I'm trying to select only the rows where phone starts with 813 and phone2 has something in it.
我试着只选择以813开头的行,而phone2有一些内容。
10 个解决方案
#1
215
Compare value of phone2
with empty string:
用空字符串比较phone2的值:
select phone, phone2
from jewishyellow.users
where phone like '813%' and phone2<>''
Note that NULL
value is interpreted as false
.
注意,NULL值被解释为false。
更多相关文章
- AppScan安全问题解决方案
- PLSQL乱码解决方案
- 数据库不支持中文解决方案(mysql)
- Mysql替代解决方案Cassandra
- [置顶] Android屏幕适配解决方案
- 物流货运移动APP解决方案
- 转:Android Studio Error:Connection timed out: connect.解决方
- android.os.NetworkOnMainThreadException的解决方案
- Android极光推送jPush混淆解决方案终极篇