Click here to Skip to main content
15,881,173 members
Home / Discussions / Database
   

Database

 
GeneralRe: OR in a JOIN Pin
Chris Meech6-Jun-12 10:07
Chris Meech6-Jun-12 10:07 
AnswerRe: OR in a JOIN Pin
Paul Conrad6-Jun-12 9:43
professionalPaul Conrad6-Jun-12 9:43 
GeneralRe: OR in a JOIN Pin
PIEBALDconsult6-Jun-12 10:38
mvePIEBALDconsult6-Jun-12 10:38 
AnswerRe: OR in a JOIN Pin
Luc Pattyn7-Jun-12 4:33
sitebuilderLuc Pattyn7-Jun-12 4:33 
GeneralRe: OR in a JOIN Pin
Bernhard Hiller7-Jun-12 22:47
Bernhard Hiller7-Jun-12 22:47 
GeneralRe: OR in a JOIN Pin
Luc Pattyn8-Jun-12 2:22
sitebuilderLuc Pattyn8-Jun-12 2:22 
AnswerRe: OR in a JOIN Pin
Jörgen Andersson7-Jun-12 6:51
professionalJörgen Andersson7-Jun-12 6:51 
AnswerRe: OR in a JOIN Pin
Luc Pattyn7-Jun-12 7:23
sitebuilderLuc Pattyn7-Jun-12 7:23 
Interesting.
IMO it can be simplified further, as the CTE isn't really necessary, so I now have:
SELECT  A.ID aID
       ,A.Field1 aField1
       ,A.Field2 aField2
       ,CASE WHEN L.ID IS NULL THEN R.ID ELSE L.ID end bID
       ,CASE WHEN L.ID IS NULL THEN R.field1 ELSE L.Field1 END bField1
       ,CASE WHEN L.ID IS NULL THEN R.Field2 ELSE L.Field2 END bField2
FROM TableB L
RIGHT OUTER JOIN TableA A ON L.Field1 = A.Field1
LEFT  OUTER JOIN TableB R ON A.Field2 = R.Field2
WHERE L.ID IS NOT NULL OR  R.ID IS NOT NULL


I have your cases depend on the ID field, not the other fields (where null might be valid)

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: OR in a JOIN Pin
Jörgen Andersson7-Jun-12 8:13
professionalJörgen Andersson7-Jun-12 8:13 
QuestionTransposing SQL Record Pin
Frank Lepkowski4-Jun-12 8:22
Frank Lepkowski4-Jun-12 8:22 
AnswerRe: Transposing SQL Record Pin
David Mujica4-Jun-12 9:56
David Mujica4-Jun-12 9:56 
GeneralRe: Transposing SQL Record Pin
FrankLepkowski4-Jun-12 11:04
FrankLepkowski4-Jun-12 11:04 
AnswerRe: Transposing SQL Record Pin
Jörgen Andersson4-Jun-12 11:22
professionalJörgen Andersson4-Jun-12 11:22 
AnswerRe: Transposing SQL Record Pin
Mycroft Holmes4-Jun-12 13:11
professionalMycroft Holmes4-Jun-12 13:11 
GeneralRe: Transposing SQL Record Pin
FrankLepkowski4-Jun-12 13:23
FrankLepkowski4-Jun-12 13:23 
GeneralRe: Transposing SQL Record Pin
Mycroft Holmes4-Jun-12 14:12
professionalMycroft Holmes4-Jun-12 14:12 
Questionsmall bank application Pin
mpkuena4-Jun-12 6:51
mpkuena4-Jun-12 6:51 
AnswerRe: small bank application Pin
Paul Conrad4-Jun-12 8:06
professionalPaul Conrad4-Jun-12 8:06 
AnswerRe: small bank application Pin
R. Giskard Reventlov4-Jun-12 8:43
R. Giskard Reventlov4-Jun-12 8:43 
JokeRe: small bank application Pin
Chris Meech4-Jun-12 8:58
Chris Meech4-Jun-12 8:58 
GeneralRe: small bank application Pin
thatraja6-Jun-12 8:46
professionalthatraja6-Jun-12 8:46 
AnswerRe: small bank application Pin
thatraja4-Jun-12 17:11
professionalthatraja4-Jun-12 17:11 
GeneralRe: small bank application Pin
Paul Conrad4-Jun-12 17:12
professionalPaul Conrad4-Jun-12 17:12 
GeneralRe: small bank application Pin
thatraja6-Jun-12 8:48
professionalthatraja6-Jun-12 8:48 
AnswerRe: small bank application Pin
vvashishta4-Jun-12 22:03
vvashishta4-Jun-12 22:03 

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.