Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys i use this code for comaprison 2 table , but return me all compariziation not only result , why ??

What I have tried:

SELECT *
FROM StfnStbl 
INNER JOIN StfnStbl_Temp 
ON StfnStbl.Symbol <> StfnStbl_Temp.Symbol;
Posted
Updated 5-Aug-22 1:38am
Comments
Richard MacCutchan 5-Aug-22 7:36am    
Without seeing the content of the two tables it is impossible to guess.

1 solution

You are JOINING two tables with an INNER JOIN, which returns all rows which match up in both tables: that'll be every pair of rows where the symbols do not match.

Did you mean to JOIN them where they DO match?
 
Share this answer
 
Comments
[no name] 5-Aug-22 8:13am    
no i want only retrun a differences
OriginalGriff 5-Aug-22 8:23am    
And that is what you are getting.
Perhaps if you gave an example of the two tables input and what you expected it might help.
[no name] 5-Aug-22 8:36am    
first table
idt Symbol
1 ETHBTC
2 BNBBTC
3 QTUMETH
4 GASBTC
5 BNBETH
6 WTCBTC
7 QTUMBTC
8 ZRXBTC
9 KNCBTC
10 MTLBTC
11 EOSBTC
12 ETCETH
13 ETCBTC
14 DNTBTC
15 OAXBTC
16 BTGBTC
17 REQBTC
18 VIBBTC
19 TRXBTC
20 TRXETH
21 POWRBTC
22 ARKBTC
23 STORJBTC
24 KMDBTC
25 NULSBTC
26 XMRBTC
27 XMRETH
28 BATBTC
29 LSKBT


second table
idt Symbol
1 ETHBTC
2 BNBBTC
3 QTUMETH
4 GASBTC
5 BNBETH
6 WTCBTC
7 QTUMBTC
8 ZRXBTC
9 KNCBTC
10 MTLBTC
11 EOSBTC
12 ETCETH
13 ETCBTC
14 DNTBTC
15 OAXBTC
16 BTGBTC
17 REQBTC
18 VIBBTC
19 TRXBTC
20 TRXETH
21 POWRBTC
22 ARKBTC
23 STORJBTC
24 KMDBTC
25 NULSBTC
26 XMRBTC
27 XMRETH
28 BATBTC
29 LSKBTC

i aspect return only one row (in this case)
29 LSKBT

for do that i also add WHERE StfnStbl.Symbol <> StfnStbl_Temp.Symbol but nothing
Richard Deeming 5-Aug-22 8:59am    
You need to join on the ID as well:
ON StfnStbl.idt = StfnStbl_Temp.idt
AND StfnStbl.Symbol <> StfnStbl_Temp.Symbol

Otherwise, you'll return every pair of rows from the cross-product of the two tables where the symbols are not equal.
OriginalGriff 5-Aug-22 9:08am    
Try JOINing by matching IDT's, and add a WHERE clause to select the Symbols that don't match:
SELECT *
FROM StfnStbl 
JOIN StfnStbl_Temp 
ON StfnStbl.IDT = StfnStbl_Temp.IDT
WHERE StfnStbl.Symbol <> StfnStbl_Temp.Symbol;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900