Selecting MySQL Columns with Non-Empty Values
In MySQL, selecting columns based on the presence of data can be achieved using various methods. Consider the task of selecting only rows where a specific column, like 'phone2', contains non-empty values.
To address this, one approach involves comparing the value of 'phone2' with an empty string. The following query demonstrates this:
select phone, phone2 from jewishyellow.users where phone like '813%' and phone2''
By comparing 'phone2' with an empty string, the query retrieves rows where 'phone2' has any non-empty value. It's important to note that NULL values are treated as false in this comparison.
This approach provides a straightforward method for selecting rows with non-empty columns, ensuring that the retrieved results meet the desired criteria.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3