Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9153013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:11:22+00:00 2026-06-17T12:11:22+00:00

I have this as one of the fields in my select statement: select …some

  • 0

I have this as one of the fields in my select statement:

select
      ...some fields
            (select ISNULL( TagNames, '') from  TagNames_CTE as tagNames 
         where  Content.ID = tagNames.EntryID) as tags 
from  SomeTable

I noticed that even when I’m using ISNULL and telling it to replace those with empty string, I’m still getting NULL back for some records. It’s not replacing them with an empty string and I don’t see why.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:11:24+00:00Added an answer on June 17, 2026 at 12:11 pm

    I think you’ll find that the subselect actually returns NULL in those cases where no rows are found.

    In cases where a row is found in TagNames_CTE where the where clause fires and TagNames is NULL, it will get converted to '' by the function.

    But where no rows are found at all, the function is not called (since there are no rows for it to work its magic on) and the result of the overall subselect is NULL, because it has to return something in that column for the outer select.

    An easy way to check is to run the subquery (without ISNULL()) on its own and see if it returns a row containing NULL or no rows at all – try some simple queries along the lines of:

    select 1,
           (select isnull (null,2) from dummytable where 1 = 0)
    from dummytable
    

    and:

    select 1,
           (select isnull (null,2) from dummytable where 1 = 1)
    from dummytable
    

    You’ll probably find that the former gives you 1, null while the latter gives you 1,2. Having tested that in MySQL with the following statement, you can see that this is most likely correct.

    > create table xyzzy (plugh integer);
    
    > insert into xyzzy values (42):
    
    > select 1,(select ifnull (null, 2) from xyzzy where 1 = 0) from xyzzy;
    1 NULL
    
    > select 1,(select ifnull (null, 2) from xyzzy where 1 = 1) from xyzzy;
    1 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with a SQL statement: Using this select a.id as ID,
I have this field in one form : <input type=text name=promocode id=promoCode value= style=width:24%
I have a class that contains a boolean field like this one: public class
I have a field aliases of type java.util.Set in one Entity . This Set
I have this one class: say InterClass . This class is declared in say,
I have this WinForms project (based on this one , but modified for SharePoint
This one is a little tricky. Say I have this XmlDocument <Object> <Property1>1</Property1> <Property2>2</Property2>
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one
Is there any way to have this: [one[two]][three] And extract this with a regex?
Ok, this one is weird, i have this code: $('#nps').submit(function(e) { e.preventDefault(); var images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.