Click here to Skip to main content
16,006,535 members
Home / Discussions / Database
   

Database

 
AnswerRe: problem record selection Pin
Colin Angus Mackay6-Jan-07 3:11
Colin Angus Mackay6-Jan-07 3:11 
GeneralRe: problem record selection Pin
araja_pandian6-Jan-07 3:14
araja_pandian6-Jan-07 3:14 
QuestionBest Encryption Strategy Pin
DougWiesnerMI5-Jan-07 10:44
DougWiesnerMI5-Jan-07 10:44 
AnswerRe: Best Encryption Strategy Pin
Ed.Poore7-Jan-07 6:38
Ed.Poore7-Jan-07 6:38 
GeneralRe: Best Encryption Strategy Pin
DougWiesnerMI8-Jan-07 2:12
DougWiesnerMI8-Jan-07 2:12 
QuestionTricky table join Pin
Wjousts5-Jan-07 2:47
Wjousts5-Jan-07 2:47 
AnswerRe: Tricky table join Pin
ednrgc5-Jan-07 6:40
ednrgc5-Jan-07 6:40 
GeneralRe: Tricky table join Pin
Wjousts5-Jan-07 7:37
Wjousts5-Jan-07 7:37 
Something like that would work. In particular I can do this:

Select A.*
FROM MyTable A
WHERE A.Item_Code NOT IN (Select Item_Code FROM MyTable WHERE Site_Code='AA') AND Site_Code in ('BB','CC','DD')
UNION
SELECT * FROM MyTable WHERE Site_Code='AA'

And that mostly works. I get all the records with Site_Code='AA' plus all the records in 'BB','CC' and 'DD' with Item_Codes not in 'AA'. The problem, of course, is that there may be a few Item_Codes in 'BB' and 'CC' but not in 'AA', which means I get duplicate records for that Item_Code. There aren't very many of them, but they do exist.

I assume I could fix the problem with something like this (not yet tested):

Select * FROM MyTable WHERE Site_Code='AA'
UNION
Select A.* FROM MyTable A WHERE A.Item_Code NOT IN
(Select Item_Code FROM MyTable WHERE Site_Code = 'AA') AND Site_Code='BB'
UNION
Select A.* FROM MyTable A WHERE A.Item_Code NOT IN
(Select Item_Code FROM MyTable WHERE Site_Code IN ('AA','BB')) AND Site_Code='CC'
UNION
Select A.* FROM MyTable A WHERE A.Item_Code NOT IN
(Select Item_Code FROM MyTable WHERE Site_Code IN ('AA','BB','CC')) AND Site_Code='DD'
...

But that just seems absolutely horrible. Is there an easier way?
GeneralRe: Tricky table join Pin
ednrgc5-Jan-07 8:31
ednrgc5-Jan-07 8:31 
GeneralRe: Tricky table join Pin
Wjousts5-Jan-07 8:47
Wjousts5-Jan-07 8:47 
QuestionHow to debug stored procedure Pin
mohd imran abdul aziz5-Jan-07 0:10
mohd imran abdul aziz5-Jan-07 0:10 
AnswerRe: How to debug stored procedure Pin
WoutL5-Jan-07 0:40
WoutL5-Jan-07 0:40 
AnswerRe: How to debug stored procedure Pin
Pete O'Hanlon5-Jan-07 2:43
mvePete O'Hanlon5-Jan-07 2:43 
GeneralRe: How to debug stored procedure Pin
mohd imran abdul aziz5-Jan-07 3:23
mohd imran abdul aziz5-Jan-07 3:23 
GeneralRe: How to debug stored procedure Pin
Mike Dimmick5-Jan-07 4:59
Mike Dimmick5-Jan-07 4:59 
QuestionBitwise operation for WHERE clause Pin
Leftyfarrell4-Jan-07 12:33
Leftyfarrell4-Jan-07 12:33 
AnswerRe: Bitwise operation for WHERE clause Pin
Colin Angus Mackay4-Jan-07 14:01
Colin Angus Mackay4-Jan-07 14:01 
GeneralRe: Bitwise operation for WHERE clause Pin
Leftyfarrell4-Jan-07 14:12
Leftyfarrell4-Jan-07 14:12 
QuestionPlaying Wav Files From Database Pin
Now_Loading4-Jan-07 11:09
Now_Loading4-Jan-07 11:09 
AnswerRe: Playing Wav Files From Database Pin
Chris Buckett4-Jan-07 21:40
Chris Buckett4-Jan-07 21:40 
GeneralRe: Playing Wav Files From Database Pin
Colin Angus Mackay5-Jan-07 4:16
Colin Angus Mackay5-Jan-07 4:16 
GeneralRe: Playing Wav Files From Database Pin
Chris Buckett5-Jan-07 4:20
Chris Buckett5-Jan-07 4:20 
Questionsql query ... Pin
groundzero1114-Jan-07 10:01
groundzero1114-Jan-07 10:01 
AnswerRe: sql query ... Pin
Colin Angus Mackay4-Jan-07 13:55
Colin Angus Mackay4-Jan-07 13:55 
GeneralRe: sql query ... Pin
groundzero1117-Jan-07 5:56
groundzero1117-Jan-07 5:56 

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.