I
I
Ivan Damaskin2015-01-14 16:48:26
MySQL
Ivan Damaskin, 2015-01-14 16:48:26

How to write a query correctly - All values ​​where the name column is not empty and discount contains VIP?

Hello everyone, help me write such a query to the database correctly,
select the client table and show all the rows in it with the condition that the name is not empty and the discount contains the word VIP
, I have such a table client
id | name | phone | birthdate | discount | visits
1 | Ivan | 077112233 | 01/01/2015 | VIP-0001 | 0
Here is my query SELECT * FROM `client` WHERE name IS NULL and discount LIKE '%VIP%' but it displays all 1000 rows for me, and should display only those whose name is filled in, which means the card was issued to the client

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Damaskin, 2015-01-14
@Joannes

Decision!
SELECT * FROM `client` WHERE name NOT LIKE '' and discount LIKE '%VIP%'

A
Armenian Radio, 2015-01-14
@gbg

In your request it is written that name is just empty. Must be name is not null

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question