selecting from 3 different tables
-
im a begginer,i have 3 different tables [customer,invoice,projects] Customer table intcid[PK] Companyname ProjectTable intprojectId[PK], intCid[FK], strName , startdate, Invoice Table intinvoiceId[PK] intCid[FK] intProjectId[FK] monTotal i want to select these tables based on the Project name i give.. if the project doesnt have invoice also i have show the output as null in the corresponing row. i given this query SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Invoice i,Customers c,Projects p WHERE p.intProjId=i.intProjectId and p.intCid=c.intCid and p.intProjId=@intProjId but it givs the value only if the project has invoice record. can any one help me??
-
im a begginer,i have 3 different tables [customer,invoice,projects] Customer table intcid[PK] Companyname ProjectTable intprojectId[PK], intCid[FK], strName , startdate, Invoice Table intinvoiceId[PK] intCid[FK] intProjectId[FK] monTotal i want to select these tables based on the Project name i give.. if the project doesnt have invoice also i have show the output as null in the corresponing row. i given this query SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Invoice i,Customers c,Projects p WHERE p.intProjId=i.intProjectId and p.intCid=c.intCid and p.intProjId=@intProjId but it givs the value only if the project has invoice record. can any one help me??
use following query SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Invoice i LEFT OUTER JOIN Projects p ON p.intProjId=i.intProjectId and p.intProjId=@intProjId LEFT OUTER JOIN Customers c ON p.intCid=c.intCid
-
use following query SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Invoice i LEFT OUTER JOIN Projects p ON p.intProjId=i.intProjectId and p.intProjId=@intProjId LEFT OUTER JOIN Customers c ON p.intCid=c.intCid
-
i think Projects is your main table .NP run following SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Projects p LEFT OUTER JOIN Invoice i ON p.intProjId=i.intProjectId LEFT OUTER JOIN Customers c ON p.intCid=c.intCid WHERE p.intProjId=@intProjId
-
i think Projects is your main table .NP run following SELECT c.intCid, c.strCompany_name, p.intProjId, p.strName, p.dteStartDate, p.dteFinalEndDate, p.strDescription, i.monTotalamount, i.intInvoiceId FROM Projects p LEFT OUTER JOIN Invoice i ON p.intProjId=i.intProjectId LEFT OUTER JOIN Customers c ON p.intCid=c.intCid WHERE p.intProjId=@intProjId