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。

更多相关文章

  1. AppScan安全问题解决方案
  2. PLSQL乱码解决方案
  3. 数据库不支持中文解决方案(mysql)
  4. Mysql替代解决方案Cassandra
  5. [置顶] Android屏幕适配解决方案
  6. 物流货运移动APP解决方案
  7. 转:Android Studio Error:Connection timed out: connect.解决方
  8. android.os.NetworkOnMainThreadException的解决方案
  9. Android极光推送jPush混淆解决方案终极篇

随机推荐

  1. 一起学android之EditText的各种使用(15)
  2. Android -- 设置textview文字居中或者控
  3. 在Android模拟器安装应用
  4. Android开发常用代码片段(三)
  5. Kotlin Anko Layout+MVP(Glide,Retrofit,
  6. APIDEMO GRIDVIEW
  7. Android(安卓)读取内存文件返回byte数组
  8. #AndroidDevSummit,就在此刻!
  9. Android TextView多行文本滚动实现
  10. Android shape 绘制图形的实例详解