Home > database >  Very strange NOT Exist query error problem
Very strange NOT Exist query error problem

Time:11-18

Two identical table structure (table A and table B)
Table B is the surface of the earth, A table placed on 192.168.1.108 server,
By adding the 192.168.1.108 links in the local SQL Server Server object
ICID field types: varchar (20)
CompanyKey field types: int

B table data:
CompanyKey ICID CreateDate
5 0008007062 2018-10-11


[r]. 192.168.1.108 MyTestDB. Dbo. A
CompanyKey ICID CreateDate
5 0008007062 2020-10-11

Now demand: hope according to CompanyKey + ICID query out what data does not exist in the table B table
 
SELECT *
The FROM [192.168.1.108] [MyTestDB] dbo. A
WHERE CompanyKey=5 AND NOT the EXISTS
(
The SELECT IC_ID
The FROM B
WHERE A.CompanyKey=B.Com panyKeyAND Anderson, CID=B.I CID
)

the above query table A and table B, obviously there are corresponding record, correct value should be no, but the query is:
CompanyKey ICID CreateDate
5 0008007062 2020-10-11

CodePudding user response:

Whether in the ICID invisible characters

CodePudding user response:

reference 1st floor RINK_1 response:
is invisible characters of ICID

I try to Update it again, that is still wrong

CodePudding user response:

Select the IC_ID is how?

CodePudding user response:

The
reference 3 floor zxm_heiye response:
Select IC_ID is behind how?

Post written is wrong, don't care about this, SQL syntax can normal execution

CodePudding user response:

refer to the second floor tiancaolin response:
Quote: refer to 1st floor RINK_1 response:

Whether ICID invisible characters of

I try to Update it again, that is still wrong



You directly under their respective operation, and see if it can query the data out

SELECT *
FROM table
WHERE CompanyKey=5 AND ICID='0008007062'

CodePudding user response:

Have built tables and data SQL not

CodePudding user response:

According to the information you write I set up a similar environment, link server + your SQL query, but the query is numerous, according to what may have neglected things

CodePudding user response:

reference 5 floor RINK_1 reply:
Quote: refer to the second floor tiancaolin response:

Quote: refer to 1st floor RINK_1 response:

Whether ICID invisible characters of

I try to Update it again, that is still wrong



You directly under their respective operation, and see if it can query the data out

SELECT *
FROM table
WHERE CompanyKey=5 AND ICID='0008007062'

can

CodePudding user response:

A, B two tables associated with the read data out of

CodePudding user response:

You can instead exists first come out the data

CodePudding user response:

SELECT * FROM [192.168.1.108] [MyTestDB] dbo. A
The LEFT OUTER JOIN ON A.Com panyKey B=B.Com panyKey and Anderson, CID=B.I CID
Where biggest reateDate IS NULL

CodePudding user response:

May be NULL at work,

CodePudding user response:

The
refer to 12 floor selling fruit net reply:
may be NULL at work,

With Null it doesn't matter, all have identified is the data,

CodePudding user response:

references 9 f XXXXn handsome response:
A, B two tables associated with the data see to you

can

CodePudding user response:

The collation posted see
Or forced to contrast with the same collation,

If it's convenient to put the two tables into a new library, then query whether there is any this kind of phenomenon,

CodePudding user response:

WHERE CompanyKey=5
If this problem

CodePudding user response:

refer to 7th floor three years 丿 response:
according to the information you write I set up a similar environment, link server + your SQL query, it is countless according to query, there may be something neglected

Actually my table fields more than these, is also very more,, just because the associated conditions has nothing to do with those fields,
I wonder could it be Null cause other columns have??????? If it is, can't understand,

CodePudding user response:

reference 15 floor gypsy song response:
stick ordering rules out see
Or forced to contrast with the same collation,

If it's convenient to put the two tables into a new library, then query whether there is any this kind of phenomenon,

Both the database collation is: Chinese_PRC_CI_AS
Data volume is too big, the environment can not imported into the new library,

CodePudding user response:

reference XXXXn handsome on 16th floor response:
WHERE CompanyKey=5
Does this problem

I just want to compare CompanyKey=5 collections, and don't write or how to write?

CodePudding user response:

You don't have this handwritten emersion environmental simulation, SQL is at sixes and sevens

CodePudding user response:

 
SELECT *
The FROM [192.168.1.108] [MyTestDB] dbo. A
WHERE CompanyKey=5 AND NOT the EXISTS
(
The SELECT ICID
The FROM B
WHERE CompanyKey='5' AND ICID='0008007062'
)

Try this?
  • Related