Fetch columns that are not empty

In this table for row 2 name is empty
I want to fetch only those column that are not empty in row 2.
How can I check that name is fetched only if it is not empty otherwise not.

Do I need to fetch entire second row and then I can check which field is not empty

if the data come from a database, you can define a condition for non-empty columns in the SQL query.

If I use like this

SELECT * FROM student WHERE name IS NULL OR name = ' ';

then also the name field is fetched .I want name should be excluded if it is empty.

Does this help? http://stackoverflow.com/questions/5285448/mysql-select-only-not-null-values

None of the query helps me.
I want something like this.
select id,name,class from student where id = 2 and if name is empty don’t select that column
is there any way to do this

name <> ‘’ AND ISNULL(name) = 0

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.