Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2008-01-02 : 06:38:49
|
| I've got this table - TableAID CapID Make Model1 36335 Ford Mondeo2 12445 Audi A33 34443 BMW 3 Series4 34334 Citroen C5I need a result set which includes all tableA but with the addition of the following fields - all boolean. Alloys, Cruise, AirCon, MetallicTo get the Alloy fields I can use this statementSELECT * FROM NVDStandardEquipment LEFT OUTER JOIN NVDDictionaryOption ON NVDStandardEquipment.SE_OptionCode = NVDDictionaryOption.DO_OptionCode WHERE NVDStandardEquipment.SE_Id = 36335 AND NVDStandardEquipment.SE_OptionCode=444If true 1 row will be returned, if false nothing is returned. Obivously SE_OptionCode=444 is for Alloys, the others have different codes.How can I combine these two into one usable view. Is it possible?Thanks |
|
|
georgev
Posting Yak Master
122 Posts |
Posted - 2008-01-02 : 08:13:20
|
depends on your table structure...Assuming the followingcars(carId, make, model)options(carID, alloys, cruise, aircon, metallic)Then you can use[CODE]SELECT c.carID , c.make , c.model , o.alloys , o.cruise , o.aircon , o.metallicFROM cars c LEFT JOIN options o ON o.carID = c.carID[/CODE] George<3Engaged! |
 |
|
|
|
|
|
|
|