0

through following query i trying to merge three things parEmail , parEmployeeLogin , and parStaffID

now in the case one is null i get whole NameValue null .

SELECT (parFirstname +' '+ parSurname) AS NAME, 
  (parEmail +','+ parEmployeeLogin +','+ parStaffID) AS NameValue 
FROM [tblParticipants] 
where parFirstname Is Not Null 
ORDER BY parFirstname

NameValue only have data in it if all three fields have data, it's fetching NAME properly....i am using this to get data out of Access file..what changes should be done in this oledb query..

Ken White
  • 123,280
  • 14
  • 225
  • 444
parthiv777
  • 22
  • 5

1 Answers1

0

NULL + anything = NULL. You've prevented partFirstName from being NULL with your WHERE clause, but if either of the other two columns is NULL, the entire result is NULL.

You'll have to either use IIF to provide alternate values for NULL columns, or change your WHERE to handle multiple NULL columns. (Untested) query for first option (don't have Access on this machine):

SELECT 
  partFirstName + ' ' + IIF(IsNull(parSurName), '<None>', parSurName) as Name,
  IIF(IsNull(parEMail), '<No Mail>', parEMail) + ', ' +
    IIF(IsNUll(parEmployeeLogin), '<No Login>', parEmployeeLogin) + ', ' +
    IIF(IsNull(parStaffID), '<No ID>', parStaffID) as NameValue
FROM 
  [tblParticipants]
WHERE 
  parFirstName IS NOT NULL
ORDER BY 
  parFirstname
Ken White
  • 123,280
  • 14
  • 225
  • 444