?????: ?? ?????????? ?? SQL ????? ??? 3.5 ??? disjunction ?? ?? ??? ?????? ?? ????? ??? ?? ??? ?????? ??

???? ?????? ???? ??????
???? ID: 2494715
??? ?? ??????? ???? | ??? ?? ??????? ????

?????

?? ?? ???? Microsoft SQL Server ??? 3.5 ??????? ?? ??? ?????? ????? ???, ?? ???? ??? ?????? ???? ???? ??? ?? ?????? ?? ???? ?? ?? ?????? ?? ?????????? ?? ?? disjunction ??? ??? ??, ??? ??? ?? ?????? ??? ??? ?? ?? ??, ?????? ?????????? ??????? ?????? ?? ???? ???? ?????:
  • ?? operands ?? ?? ?????? ??? ???? ?????? ?? ?? ???????
  • Operands ?????????? ????????????? ?? ????? ?????? ??? ?????, ?? ??????????? ?? ????? ????????????? ??? ???? ?? ??? ???? ???? ???
  • ???? ?????? ?? ???????? ????? ????? ????? ?? ???? ??? ????????? ????? ?? ??? ??? ?? ?? ??????????? ?? ????? ???? ?? ?? ????? ?? ??? ??? ?????? ??? ?????, ??????????? ?? ?? ?????????? ?? ???? ?? ???? ???
?????? ?? ???, SQL Server ??? 3.5 ??????? ??? ??????????? ?? ????? ????? ?????? ?????, ??? ????
CREATE TABLE T1(
 C1 int,
 C2 int
)
GO
CREATE INDEX IND_T1 ON T1 (C1, C2)
GO
CREATE TABLE T2(
 C1 int,
 C2 int
)
GO
CREATE INDEX IND_T2 ON T2 (C1, C2)
GO
INSERT INTO T1 VALUES (1, 0)
GO
INSERT INTO T1 VALUES (2, 0)
GO
INSERT INTO T2 VALUES (1, -1)
GO
INSERT INTO T2 VALUES (2, 0)
GO
???? ???, ?? ????? ?????? ?????:
SELECT T1.C1 [T1.C1], T1.C2 [T1.C2], T2.C1 [T2.C1], T2.C2 [T2.C2]
FROM T1 INNER JOIN T2 ON
T1.C1 = T2.C1
AND (T1.C2 = T2.C2 OR T2.C2 = -1)
GO
?? ?????? ?? ????? ?? ???, ?? ????? ??? ?????? ??????? ???? ??:
?? ?????? ?? ??????? ?????? ?????? ?? ??????? ????
T1.C1T1.C2T2.C1T2.C2
2020
???????, ?? ?????????? ?????? ?? ???????:
?? ?????? ?? ??????? ?????? ?????? ?? ??????? ????
T1.C1T1.C2T2.C1T2.C2
101-1
2020
????? ?? ????? ???? ??? ?? ?? ?????? ???? ?? ????????????? ?????????? ?? ?? ????????????? ???? ?? ??? ???????? ?? ?? ????? ?????? ????? ??? ?????? ?? ???, ?? ?????? ???? ?? ??:
SELECT T1.C1 [T1.C1], T1.C2 [T1.C2], T2.C1 [T2.C1], T2.C2 [T2.C2]
FROM T1 INNER JOIN T2 ON
T1.C1 = T2.C1
WHERE T1.C2 = T2.C2 OR T2.C2 = -1
GO

????????

?? ?????? ?? ?? ???? ???? ???????? ????? ?????? ?????? 4 SQL Server ??? 3.5 ?????? ??? 2 ?? ??? ????? ???

????? ?????? ?????? 4 SQL Server ??? 3.5 ?????? ??? 2 ?? ??? ??????? ???? ?? ??? ???? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ?????????? ???? ?????? ????? ????:
2516828 SQL ????? ?? ??? ????? ?????? 4 ??????? 3.5 ?????? ??? 2

????? ?????????

?? ?????? ?? ???????? ?? ?? ???, ????? ??????? ??? ?? ???? ?? ?? ????? ???? ?????? ?????????:

???? 1

??????????? ?? ????? ???? ?? ??? ?????? ??? ?????? ??????? ?? ????? ????? ?????? ?? ???, ??????????? ?? ????? ???? ?? ??? ????? ?????? ?????:
SELECT T1.C1 [T1.C1], T1.C2 [T1.C2], T2.C1 [T2.C1], T2.C2 [T2.C2]
FROM T1 INNER JOIN T2 WITH (INDEX(0)) ON
T1.C1 = T2.C1
AND (T1.C2 = T2.C2 OR T2.C2 = -1)
GO 

???? 2

Re-write ?????? "?????" ??? ??? ???????? ?????? ?????? ?? ???? ?? ???:
SELECT T1.C1 [T1.C1], T1.C2 [T1.C2], T2.C1 [T2.C1], T2.C2 [T2.C2]
FROM T1 INNER JOIN T2 ON
(T1.C1 = T2.C1 AND T2.C2 = -1) OR (T1.C1 = T2.C1 AND T1.C2 = T2.C2)

??????

Microsoft ?? ?????? ?? ?? ?? ?? "?? ?? ????" ???? ??? ???????? Microsoft ???????? ??? ?? ?????? ???

???

???? ID: 2494715 - ????? ???????: 27 ?????? 2011 - ??????: 2.0
??????: 
kbfix kbqfe kbexpertiseadvanced kbsurveynew kbmt KB2494715 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:2494715

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com