tags:

views:

148

answers:

3

I know that most sql server software allows you to do "A Update on a Join", but I am wondering, is this in the SQL standards? (eg. can I assume that any software package allows this?)

Note: I am asking this because I am writing a database library that should be easily extensible to database software that is not included in the original build. As such there's no point in answering with a remark such as "a, b, c and b all allow that - together they make up the lionshare of the market, so you can assume that all software packages allow that". No, I am interested in whether it is in the standards or not.

+2  A: 

You're presuming that all software packages adhere to ANSI SQL Standards.....in reality, none of them that I'm aware of adhere completely to the standards.

If you're looking to adhere to ANSI SQL standards, the best place to start would be with the documented standards themselves. Here's the SQL-92 document:

http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt

Aaron Alton
I am not under that impression.As far as I know all widely used software provides this functionality. If, in addition to that, it is in the standard, I can use it and I'll be able to support any sql software that supports the standards well enough. If they don't support the function while it is in the standard, their bad.Now, if it is not in the standards then it is a different story. In that case I simply used a function that some big company made up and some others followed, and for that reason I will not be able to support sql software who did not follow suit.
Jasper
Thanks for the link. I will look through it - though it is a pain to find anything you are looking for in it, so if anyone would happen to know, that would still be appreciated.
Jasper
+1  A: 

If I understand the question right, I think the answer is no, there is no standard "update based on a join". The postgres manual page for UPDATE includes this under "Compatibility":

This command conforms to the SQL standard, except that the FROM and RETURNING clauses are PostgreSQL extensions.

While this doesn't explicitly say there isn't, the Compatibility notes in that manual generally note when there is a related, but not identical, feature in the standard.

IMSoP
+1  A: 

According to the ANSI SQL-92 standard, an UPDATE on JOINed tables is NOT part of the standards; See http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt sections 13.9 and 13.10 (you'll have to search for 391, the page number).

I tried to find an ANSI 2003 standard, but the closest I came was here: www.wiscorp.com/sql_2003_standard.zip (a late draft). There was no substantial difference between the two in regards to the UPDATE statement and JOIN syntax.

Stu

Stuart Ainsworth