Spójrzmy na przykład Oracle SQL, który działa perfekcyjnie: daneT-SQL równoważna Oracle SQL gdzie klauzuli z wieloma kolumnami
Sample:
SQL> create table test (a number, b number);
SQL> insert into test values(1, 1);
SQL> insert into test values(1, 2);
SQL> insert into test values(1, 3);
SQL> insert into test values(1, 4);
SQL> insert into test values(1, 5);
SQL> insert into test values(2, 1);
SQL> insert into test values(2, 2);
SQL> insert into test values(2, 3);
SQL> insert into test values(2, 4);
SQL> insert into test values(2, 5);
SQL> insert into test values(4, 1);
SQL> select * from test;
A B
---------- ----------
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
2 4
2 5
4 1
Zapytanie:
SQL> select * from test where (a, b) in (select 1, 4 from dual);
A B
---------- ----------
1 4
tutaj sql-fiddle: http://www.sqlfiddle.com/#!4/8375e/3/0
Proste pytanie: czy istnieje odpowiednik w MS SQL powyższej klauzuli "where (a, b)"? Rozglądałem się w Google, MS Docs i nic do tej pory ...
http://stackoverflow.com/questions/4452539/sql-server-in-clause-with-multiple-fields – Habib
Jak to działa w Oracle? Czy to jest to samo co 'wybierz * z testu gdzie a = 1 i b = 4;'? Jaka jest zatem korzyść? –
N.B: '(a, b)' jest nazywany "wyrażeniem wartości wiersza" lub krotką. To może pomóc w googlowaniu. –