Click here to Skip to main content
15,907,874 members
Home / Discussions / Database
   

Database

 
GeneralRe: Nsted SELECT statements Pin
Christian Graus11-Nov-04 9:05
protectorChristian Graus11-Nov-04 9:05 
GeneralRe: Nsted SELECT statements Pin
Colin Angus Mackay4-Nov-04 20:29
Colin Angus Mackay4-Nov-04 20:29 
GeneralRe: Nsted SELECT statements Pin
Den2Fly4-Nov-04 21:25
Den2Fly4-Nov-04 21:25 
GeneralRe: Nsted SELECT statements Pin
Christian Graus4-Nov-04 22:19
protectorChristian Graus4-Nov-04 22:19 
GeneralCall multiple stored procs in the same query Pin
Luis Alonso Ramos4-Nov-04 7:12
Luis Alonso Ramos4-Nov-04 7:12 
GeneralRe: Call multiple stored procs in the same query Pin
Christian Graus4-Nov-04 12:30
protectorChristian Graus4-Nov-04 12:30 
GeneralJOIN with optional field Pin
Luis Alonso Ramos4-Nov-04 6:33
Luis Alonso Ramos4-Nov-04 6:33 
GeneralRe: JOIN with optional field Pin
Edbert P4-Nov-04 11:08
Edbert P4-Nov-04 11:08 
I think the simple answer is to use LEFT JOIN instead of INNER JOIN.
Since you want to still return data from dbo.Sales no matter whether you have Exterior package/Interior package or not, you need to specify
Sales LEFT JOIN Packages.

Here's an example of how you should write it:
ALTER PROCEDURE dbo.GetSaleInfo
(@ID_sale int)
AS SELECT     dbo.Sales.Date, dbo.Sales.Time, dbo.Vehicles.Make + ' ' + dbo.Vehicles.Model AS CarModel, dbo.Packages.Name AS ExteriorPackage, 
                      Packages_1.Name AS InteriorPackage, dbo.Promotions.Name AS Promotion
FROM         dbo.Sales INNER JOIN
                      dbo.Vehicles ON dbo.Sales.ID_vehicle = dbo.Vehicles.ID_vehicle LEFT JOIN
                      dbo.Packages ON dbo.Sales.ExteriorPackage = dbo.Packages.ID_package INNER JOIN
                      dbo.Promotions ON dbo.Sales.ID_promotion = dbo.Promotions.ID_promotion LEFT JOIN
                      dbo.Packages Packages_1 ON dbo.Sales.InteriorPackage = Packages_1.ID_package
WHERE     (dbo.Sales.ID_sale = @ID_sale)


I hope that solves your problem Smile | :)

Edbert P.
Sydney, Australia.
GeneralRe: JOIN with optional field Pin
Luis Alonso Ramos4-Nov-04 14:05
Luis Alonso Ramos4-Nov-04 14:05 
GeneralFind out if a table name already exists Pin
veronique4-Nov-04 5:32
veronique4-Nov-04 5:32 
GeneralRe: Find out if a table name already exists Pin
Colin Angus Mackay4-Nov-04 6:59
Colin Angus Mackay4-Nov-04 6:59 
GeneralRe: Find out if a table name already exists Pin
veronique4-Nov-04 22:38
veronique4-Nov-04 22:38 
Questionhow to obtain in a fecht a dir result? Pin
Anonymous3-Nov-04 23:56
Anonymous3-Nov-04 23:56 
GeneralStored Procedure Pin
Its due when3-Nov-04 17:52
Its due when3-Nov-04 17:52 
GeneralRe: Stored Procedure Pin
Colin Angus Mackay4-Nov-04 0:42
Colin Angus Mackay4-Nov-04 0:42 
GeneralRe: Stored Procedure Pin
Grimolfr5-Nov-04 9:43
Grimolfr5-Nov-04 9:43 
GeneralRe: Stored Procedure Pin
Colin Angus Mackay5-Nov-04 10:44
Colin Angus Mackay5-Nov-04 10:44 
GeneralRe: Stored Procedure Pin
Grimolfr5-Nov-04 15:17
Grimolfr5-Nov-04 15:17 
GeneralRe: Stored Procedure Pin
Colin Angus Mackay5-Nov-04 20:16
Colin Angus Mackay5-Nov-04 20:16 
GeneralRe: Stored Procedure Pin
Its due when7-Nov-04 17:22
Its due when7-Nov-04 17:22 
GeneralTo Get the Id from the database which are not deleted Pin
Irsh3-Nov-04 2:14
Irsh3-Nov-04 2:14 
GeneralAdding or Substracting time spans from a DateTime SQL value Pin
Den2Fly2-Nov-04 23:32
Den2Fly2-Nov-04 23:32 
GeneralRe: Adding or Substracting time spans from a DateTime SQL value Pin
Colin Angus Mackay3-Nov-04 0:09
Colin Angus Mackay3-Nov-04 0:09 
GeneralRe: Adding or Substracting time spans from a DateTime SQL value Pin
Den2Fly3-Nov-04 12:15
Den2Fly3-Nov-04 12:15 
GeneralRecordSet vs DataSet Pin
Salil Khedkar2-Nov-04 22:13
Salil Khedkar2-Nov-04 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.