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

  • Home
  • SEARCH
  • 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 6656089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:36:02+00:00 2026-05-26T01:36:02+00:00

I’m using SQL Server. I’ve 3 tables : tblUser tblAudit tblEnum The tblAudit has

  • 0

I’m using SQL Server. I’ve 3 tables :

  1. tblUser
  2. tblAudit
  3. tblEnum

The tblAudit has got 4 columns :

nUserId, nID: These two columns point to the tblUser

vFromValue, vToValue: These two columns point to the tblEnum

Now, I need to show the actual values from the tblUser and tblEnum based on the IDs present in the tblAudit table.
The query that I have written looks something like this :

SELECT A.aEventID,
U.tName AS MakerChecker,
U2.tName AS OnUser,
VLE.tDisplayName AS FromValue,
VLE2.tDisplayName AS ToValue,
A.dChangeTime AS Timestamp
FROM tblAudit A INNER JOIN tblUser U ON A.nUserId = U.aUserId
INNER JOIN tblUser U2 ON A.nID = U2.aUserId
INNER JOIN tblEnum VLE ON A.vFromValue = VLE.nIndex OR (A.vFromValue IS NULL)
INNER JOIN tblEnum VLE2 ON  A.vToValue = VLE2.nIndex OR (A.vToValue IS NULL)

Because the values in the Audit table is null for the columns vFromValue and vToValue for some rows, those values are not coming as NULL but the previous value.
How can I display the null values intact by changing the above query? Please help.

  • 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-05-26T01:36:02+00:00Added an answer on May 26, 2026 at 1:36 am

    Since the tblAudit.vFromValue and tblAudit.vToValue have NULLs, try this:

    SELECT A.aEventID,
           U.tName AS MakerChecker,
           U2.tName AS OnUser,
           VLE.tDisplayName AS FromValue,
           VLE2.tDisplayName AS ToValue,
           A.dChangeTime AS Timestamp
    FROM 
         ( SELECT aEventID, nUserId, nID, dChangeTime  
                , COALESCE(vFromValue, -9999) AS vFromValue   --- some non-existent
                , COALESCE(vToValue, -999) AS vToValue        --- value
           FROM tblAudit
         ) AS A 
      INNER JOIN tblUser U
        ON A.nUserId = U.aUserId
      INNER JOIN tblUser U2 
        ON A.nID = U2.aUserId
      LEFT JOIN tblEnum VLE 
        ON A.vFromValue = VLE.nIndex
      LEFT JOIN tblEnum VLE2 
        ON  A.vToValue = VLE2.nIndex
    

    or this:

    SELECT A.aEventID,
           U.tName AS MakerChecker,
           U2.tName AS OnUser,
           ( SELECT VLE.tDisplayName
             FROM tblEnum VLE 
             WHERE A.vFromValue = VLE.nIndex
           ) AS FromValue,
           ( SELECT VLE2.tDisplayName
             FROM tblEnum VLE2 
             WHERE A.vToValue = VLE.nIndex
           ) AS ToValue,
           A.dChangeTime AS Timestamp
    FROM tblAudit AS A 
      INNER JOIN tblUser U
        ON A.nUserId = U.aUserId
      INNER JOIN tblUser U2 
        ON A.nID = U2.aUserId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build

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.