Click here to Skip to main content
15,922,325 members
Home / Discussions / Database
   

Database

 
GeneralRe: sql/inner join statement Pin
George L. Jackson18-May-06 16:09
George L. Jackson18-May-06 16:09 
QuestionSQL Server Not Connecting Pin
Brendan Vogt18-May-06 0:32
Brendan Vogt18-May-06 0:32 
AnswerRe: SQL Server Not Connecting Pin
r.stropek4-Jun-06 5:59
r.stropek4-Jun-06 5:59 
QuestionMAXIMUM Leength of varchar Pin
NICE TO MEET18-May-06 0:28
NICE TO MEET18-May-06 0:28 
AnswerRe: MAXIMUM Leength of varchar Pin
Colin Angus Mackay18-May-06 0:35
Colin Angus Mackay18-May-06 0:35 
QuestionCombobox Pin
ADY00717-May-06 22:52
ADY00717-May-06 22:52 
QuestionComparison of two tables to catch mismatch in data Pin
Vishucool17-May-06 20:47
Vishucool17-May-06 20:47 
AnswerRe: Comparison of two tables to catch mismatch in data Pin
Jim Conigliaro19-May-06 2:11
Jim Conigliaro19-May-06 2:11 
You've got a number of options.
First of all, you could use the comparisons that are in your case statements as a where clause ...

WHERE<br />
A.branch_name<>B.branch_name<br />
OR A.book_ISBN<>B.book_ISBN<br />
OR A.book_name<>B.book_name 


Or you could make your original query into an in-line table and select from it:

Select * FROM<br />
(<br />
SELECT A.branch_name,<br />
CASE WHEN A.branch_name=B.branch_name THEN 'Y' ELSE 'N' END as "Comp_Branch",<br />
A.book_ISBN, <br />
CASE WHEN A.book_ISBN=B.book_ISBN THEN 'Y' ELSE 'N' END as "Comp_book_ISBN",<br />
A.book_name,<br />
CASE WHEN A.book_name=B.book_name THEN 'Y' ELSE 'N' END as "Comp_book_name"<br />
FROM Tablea AS A<br />
LEFT OUTER JOIN Tableb AS B ON A.branch_name = B.branch_name<br />
) Comparison<br />
WHERE Comp_Branch = 'N' or Comp_book_ISBN = 'N' or Comp_book_name = 'N'


If you have multiple uses for this information, (e.g. sometimes you just want to see the comparisons where the ISBNs are different) then you may want to create a view from your original query and then select from the view:

Select * from COMPARISON_VIEW<br />
WHERE Comp_Branch = 'N' or Comp_book_ISBN = 'N' or Comp_book_name = 'N'


Jim Conigliaro
jconigliaro@ieee.org

-- modified at 8:11 Friday 19th May, 2006
QuestionError Message Pin
NICE TO MEET17-May-06 20:34
NICE TO MEET17-May-06 20:34 
QuestionSQL Server 7.0 Database (Suspect)? Pin
Rashar17-May-06 8:32
Rashar17-May-06 8:32 
QuestionTime interveal question Pin
NaNg1524117-May-06 7:53
NaNg1524117-May-06 7:53 
AnswerRe: Time interveal question Pin
Eric Dahlvang17-May-06 8:45
Eric Dahlvang17-May-06 8:45 
GeneralRe: Time interveal question Pin
NaNg1524117-May-06 9:11
NaNg1524117-May-06 9:11 
GeneralRe: Time interveal question Pin
Eric Dahlvang17-May-06 9:17
Eric Dahlvang17-May-06 9:17 
GeneralRe: Time interveal question Pin
NaNg1524117-May-06 9:19
NaNg1524117-May-06 9:19 
QuestionHow to make copy of db Pin
leckey17-May-06 6:43
leckey17-May-06 6:43 
AnswerRe: How to make copy of db Pin
Colin Angus Mackay17-May-06 7:00
Colin Angus Mackay17-May-06 7:00 
AnswerRe: How to make copy of db Pin
Saqib Mehmood17-May-06 18:39
Saqib Mehmood17-May-06 18:39 
GeneralRe: How to make copy of db Pin
Colin Angus Mackay17-May-06 20:15
Colin Angus Mackay17-May-06 20:15 
GeneralRe: How to make copy of db Pin
Saqib Mehmood17-May-06 20:22
Saqib Mehmood17-May-06 20:22 
GeneralRe: How to make copy of db Pin
furher24-May-06 2:29
furher24-May-06 2:29 
QuestionQuestion about DataSet and DataAdapter in VS8 Pin
Roberto Ferraris17-May-06 5:51
Roberto Ferraris17-May-06 5:51 
AnswerRe: Question about DataSet and DataAdapter in VS8 Pin
Roberto Ferraris17-May-06 22:35
Roberto Ferraris17-May-06 22:35 
QuestionODBC connection Pin
Paps217-May-06 5:00
Paps217-May-06 5:00 
QuestionCan i add column to the middle of table in sql server. Pin
sharma sanjeev17-May-06 3:25
sharma sanjeev17-May-06 3:25 

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.