Remove Null Values from MYSQL during select

Ahmad

I have a survey form which records multiple responses in a MYSQL table and each member can refer to a different member in a different response or choose not to which will then be set as NULL as the table below.

membername-----referralto
Mike  -------- NULL
Ali  --------  NULL 
Mike  -------  Jack  
Ali  --------  Jill

I want the names of members and who the referrals were for. So here's what i tried;

SELECT membername, referralto 
FROM responses

This query returns me the NULL Values in the referralto fields as well. Is there a way i can filter out the NULL Values? I even tried this as well but it didn't work.

SELECT membername, NULLIF( referralto, '' )  AS member 
FROM responses

Thank you.

Amarnasan

Have you tried just adding "where referralto is not null"?

SELECT membername, NULLIF( referralto, '' )  AS member 
FROM responses
WHERE referralto IS NOT NULL

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive