MySQL select where column is not empty

后端 未结 13 2155
深忆病人
深忆病人 2020-11-30 18:18

In MySQL, can I select columns only where something exists?

For example, I have the following query:

select phone, phone2
from jewishyellow.users
wh         


        
13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 18:30

    you can use like operator wildcard to achieve this:

    SELECT t.phone, 
           t.phone2 
    FROM jewishyellow.users t
    WHERE t.phone LIKE '813%' 
      AND t.phone2 like '[0-9]';
    

    in this way, you could get all phone2 that have a number prefix.

提交回复
热议问题