Pröva med LEFT OUTER JOIN
Hej! Jag håller på med en sql sökning, där ja ska ha ut massor av värden.
Ifall alla i ifyllda funkar det kanon, men om nåt värde är NULL tex, så skiter sig hela koden och allt blir tomt.
hur löser jag detta? Hittade inget direkt när jag sökte.
select
PRHeaderTemplate.Title,
PRHeaderTemplate.Description,
PRHeaderTemplate.foreignid,
PRHeaderTemplate.Origin,
PRHeaderTemplate.Erranddescription,
PRHeaderTemplate.Impact,
PRHeaderTemplate.Solutions,
PRHeaderTemplate.Downtime,
PRHeaderTemplate.Duedate,
PRHeaderTemplate.MinRegTime,
CMProducts.ProductName,
PRType.PRTypeName,
PRSeverityType.Description,
CMCountry.Country as CountryName,
CMCompanies.CompName,
Responsible.Name as ResponsibleName,
Assigned.Name as AssignedToName,
PRStatusType.Description,
PRSourceType.SourceName,
PRErrorTypes.ErrorName,
CMProductsVersions.Version,
PRApps.AppName,
CMProcess.ProcessName,
PRInvoiceStatus.InvoiceStatusName,
CMWorkType.WorkTypeName,
reportedbyperson.Name
from
PRHeaderTemplate
INNER JOIN PRType ON PRHeaderTemplate.PRTypeId = PRType.PRTypeID
INNER JOIN PRSeverityType ON PRHeaderTemplate.SeverityId = PRSeverityType.SeverityId
INNER JOIN CMCountry ON (SELECT CountryID from CMCompanies where compid = PRHeaderTemplate.invoicecompany) = CMCountry.CountryId
INNER JOIN CMCompanies ON PRHeaderTemplate.invoicecompany = CMCompanies.CompId
INNER JOIN CMCompanyPeople AS Responsible ON PRHeaderTemplate.ResponsiblePersonId = Responsible.PersonId
INNER JOIN CMCompanyPeople AS Assigned ON PRHeaderTemplate.AssignedToPersonId = Assigned.PersonId
INNER JOIN CMProducts ON PRHeaderTemplate.ProdId = CMProducts.Prodid
INNER JOIN PRStatusType ON PRHeaderTemplate.StatusId = PRStatusType.StatusId
INNER JOIN PRSourceType ON PRHeaderTemplate.SourceId = PRSourceType.SourceId
INNER JOIN PRErrorTypes ON PRHeaderTemplate.ErrorTypeId = PRErrorTypes.ErrorTypeId
INNER JOIN CMProductsVersions ON PRHeaderTemplate.ProductVersionId = CMProductsVersions.ProductVersionId
INNER JOIN PRApps ON PRHeaderTemplate.AppId = PRApps.Appid
INNER JOIN CMProcess ON PRHeaderTemplate.processid = CMProcess.ProcessId
INNER JOIN PRInvoiceStatus ON PRHeaderTemplate.invoicestatusid = PRInvoiceStatus.InvoiceStatusId
INNER JOIN CMWorkType ON PRHeaderTemplate.worktypeid = CMWorkType.WorkTypeId
INNER JOIN CMCompanyPeople AS reportedbyperson ON PRHeaderTemplate.reportedby = reportedbyperson.PersonId
where PRHeaderTemplate.Id = '16'
