0
votes

I have a web app where users can fill forms and results are registered into a MySQL DB. Here is the DB : USERS(id,name,email,extras)

If users use form #1, id, name and email are filled in DB. If users use form #2, id and extras are filled in DB.

So I have a table like :

1 | John      | [email protected]     | 

2 | Johnny    | [email protected] | 

3 | undefined | undefined         | "name: Dumbo, email: [email protected]"

I'd like to extract name and email from all rows where extras is empty : this query is okay. I'd like to extract extras from rows where name and email are undefined. And combine these queries.

How can I do that?

Thanks.

1
What do you mean "undefined"? Null? - Steve Smith
No, a string 'undefined' is written - Ty Yt

1 Answers

0
votes
SELECT * FROM USERS 
WHERE COALESCE(extras) = '' OR 
(name = 'undefined' AND email = 'undefined');