I have a table (datas):
line | account | name | |
---|---|---|---|
1 | 1000 | Reyes VonRueden Sr. | [email protected] |
1 | 1000 | Dr. Elena Bartell V | |
1 | 1000 | Lucio Wehner | |
2 | 1000 | April Hansen | |
2 | 1000 | Amy Waelchi | [email protected] |
2 | 1000 | Tremaine Cassin | |
3 | 1000 | Susana White Jr. | [email protected] |
3 | 1000 | Roxane Hoeger | |
3 | 1000 | Prof. Eric Boehm | |
4 | 1000 | Miles Considine | ** ** |
4 | 1000 | Araceli Effertz | ** ** |
4 | 1000 | Prof. Adolph Pacocha | ** ** |
5 | 1000 | Prof. Rafaela Hills | [email protected] |
5 | 1000 | Delta Becker | |
5 | 1000 | Aditya Ratke | [email protected] |
6 | 1000 | Miss Elaina Aufderhar Sr. | [email protected] |
6 | 1000 | Miss Stephanie Russel IV | |
6 | 1000 | Dr. Ramiro Marks IV | [email protected] |
7 | 1000 | Garfield Kozey | ** ** |
7 | 1000 | Gene Hilpert | ** ** |
The line and account fields clearly define a customer.
The name field is a worker.
I am looking for customers (line+account) whose name field does not have an email address.
In this case the results are: 4-1000 and 7-1000.
I can solve it with 2 queries and using excel, but it would be faster in mysql.
thanks if you help 😉
3
Answers
As every email should have the
@
symbol, you should exclude all entries with emails. It is less performant thanWHERE email IS NULL
though (won’t matter though until you go through A LOT of data). You should make sure that your tables are clean, fields only filled with valid data or nothing, allowing you to use queries not relying on substring search where possible.Anyway the expected result would be:
Here is the query you’re looking for.
This query will give you all fields that do not have an email.
If you’re however looking for records that do not have a valid email address, then use the query below.
To accomplish this, utilize a SQL JOIN statement. Here is a search that ought to produce the outcomes you need:
hope this is helpful!