Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > MS SQL Server > operator *=


Автор: gelo86 29.12.2007, 10:40
Sto delajet operator *=?.
Naprimer select .. from currency a, currency_price b where where a.currency_id *= b.currency_id -- Kakoj smysl etogo sql zaprosa?

Автор: Akina 29.12.2007, 11:31
Код

a.currency_id *= b.currency_id 

это короткая форма записи
Код

a.currency_id = a.currency_id * b.currency_id 

Автор: gelo86 29.12.2007, 12:11
a eto: a.currency_date *= b.currency_date? kakoj smysl mozet byt etogo?

Автор: Servena 29.12.2007, 22:40
Это устаревшая запись условия в объединении - по каким полям происходит Джоин.
Я даже не смог ее найти в МСДН. Эта запись не входит в стандарт ANSI и скоро уже не будет поддерживаться.

Лучше писать так:
Код

SELECT .. 
FROM currency AS a
INNER JOIN currency_price AS b 
      ON a.currency_id = b.currency_id



Автор: Akina 30.12.2007, 00:23
Во блин... век живи - век учись... вот что найдено в MSDN в разделе по Microsoft® SQL Server™ 2000

Цитата(Query Designer Considerations for SQL Server Databases)

Creating Outer Joins
In the SQL pane, you can use the SQL Server-specific *= and =* operators to specify an outer join. When you change panes or execute the query, the Query Designer reformats your SQL statement, and replaces *= with LEFT OUTER JOIN and =* with RIGHT OUTER JOIN.

Цитата(Accessing and Changing Relational Data)

Transact-SQL Joins
In earlier versions of Microsoft® SQL Server™ 2000, left and right outer join conditions were specified in the WHERE clause using the *= and =* operators. In some cases, this syntax results in an ambiguous query that can be interpreted in more than one way. SQL-92 compliant outer joins are specified in the FROM clause and do not result in this ambiguity. Because the SQL-92 syntax is more precise, detailed information about using the old Transact-SQL outer join syntax in the WHERE clause is not included with this release. The syntax may not be supported in a future version of SQL Server. Any statements using the Transact-SQL outer joins should be changed to use the SQL-92 syntax.

The SQL-92 standard does support the specification of inner joins in either the FROM or WHERE clause. Inner joins specified in the WHERE clause do not have the same problems with ambiguity as the Transact-SQL outer join syntax.

Автор: Servena 30.12.2007, 11:22
Подведу итог:

1. Правильно будет (спасибо Акине - уточнил что это не внутренее, а внешнее соединение) написать так:
Код

SELECT .. 
FROM currency AS a
LEFT OUTER JOIN currency_price AS b 
      ON a.currency_id = b.currency_id
 

2. Нужно придерживаться стандарта ANSI, и SQL Server 2005(в отличие от 6 или 7 версий) уже приблизился к этому вплотную. Поэтому все устаревшие виды записей нужно исключить и не изучать, потому что в следующей версии они уже не будут поддерживаться.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)