ansi-sql

'LEFT JOIN' vs 'LEFT OUTER JOIN'

╄→尐↘猪︶ㄣ 提交于 2019-12-10 10:16:52
问题 I know there is really no difference, but is 'LEFT JOIN' an ANSI form or are there any RDBMS's that will fail 'LEFT JOIN' and require 'LEFT OUTER JOIN'. [I am asking here so I can save a few clicks, form fillings, etc to get the correct ANSI standard!] 回答1: [OUTER] is optional, per the ANSI spec (92, but I'm sure later versions also cover it). Of course, you're assuming that every SQL product is ANSI compatible. For joins, they probably are.. 回答2: ANSI JOINS http://www.oratechinfo.co.uk/ansi

Someway to do `where booleanvalue=false` on both Sql Server and PostgreSQL?

心已入冬 提交于 2019-12-10 00:50:38
问题 I am attempting to make an application capable of running on both Sql Server and PostgreSQL. I can not seem to find a common expression that is basically select * from table where booleancol=false on SQL Server I must do(which is very confusing because the default value for bit types must be true or false, but you can't assign them to true or false or test against it) select * from table where booleancol=0 on PostgreSQL I must do select * from table where booleancol is false There are quite a

column order in SELECT * statement - guaranteed?

让人想犯罪 __ 提交于 2019-12-07 02:44:24
问题 I am using an ORM (sqlalchemy) to fetch data from a PG database. I want to avoid specifying all the table column names in my hand crafted SQL statements*. My assumption so far is that the returned columns are in the order of the DDL statements used to create the db tables. So far this is working - but I want to know if this is merely luck, or if it is specifically addressed in the (ANSI) SQL specification. i.e. does ANSI SQL (and thus presumably the database) guarantee the order of columns

ANSI 92 Recursive SQL Statement required

删除回忆录丶 提交于 2019-12-06 09:20:08
I am translating SQL Server SQL Statements into their ANSI generic equivalent at present, and am stuck with a recursive statement using a WITH statement. For the sake of concentrating on the issue, I'll simplify the issue as follows If I have two tables ReportingUnit col1: Key col2: ParentReportingUnitKey Facility col1: Key col2: ParentReportingUnitKey This structure is describing a hierarchy of reporting units down to a facility, where a reporting unit may have 0 .. 1 direct parent reporting units and 0 .. n child reporting units. A facility is a 'leaf' record, that links to a reporting unit.

'LEFT JOIN' vs 'LEFT OUTER JOIN'

最后都变了- 提交于 2019-12-05 18:23:15
I know there is really no difference, but is 'LEFT JOIN' an ANSI form or are there any RDBMS's that will fail 'LEFT JOIN' and require 'LEFT OUTER JOIN'. [I am asking here so I can save a few clicks, form fillings, etc to get the correct ANSI standard!] [OUTER] is optional, per the ANSI spec ( 92 , but I'm sure later versions also cover it). Of course, you're assuming that every SQL product is ANSI compatible. For joins, they probably are.. ANSI JOINS http://www.oratechinfo.co.uk/ansi_joins.html Note, the OUTER can be dropped, since, by definition, LEFT, RIGHT and FULL JOINs MUST be OUTER joins

column order in SELECT * statement - guaranteed?

馋奶兔 提交于 2019-12-05 05:29:23
I am using an ORM (sqlalchemy) to fetch data from a PG database. I want to avoid specifying all the table column names in my hand crafted SQL statements*. My assumption so far is that the returned columns are in the order of the DDL statements used to create the db tables. So far this is working - but I want to know if this is merely luck, or if it is specifically addressed in the (ANSI) SQL specification. i.e. does ANSI SQL (and thus presumably the database) guarantee the order of columns returned in a SELECT * statement? I am using PostgreSQL 8.4 as my backend db yes, I am aware that using

Netezza UPDATE from one table to another

為{幸葍}努か 提交于 2019-12-04 23:09:52
问题 This is my query that does not work in Netezza: UPDATE TABLE1 A SET A.COL1= (SELECT DISTINCT B.COL1 FROM TABLE2 B WHERE B.ID= A.ID AND B.DeptID=104) WHERE A.DeptID=3 How do I re-write this query? Please help. 回答1: UPDATE TABLE1 A SET A.COL1 = B.COL1 FROM TABLE2 B WHERE A.ID = B.ID AND A.DeptID = 3 AND B.DeptID = 104; 来源: https://stackoverflow.com/questions/25165835/netezza-update-from-one-table-to-another

Someway to do `where booleanvalue=false` on both Sql Server and PostgreSQL?

泪湿孤枕 提交于 2019-12-04 22:49:58
I am attempting to make an application capable of running on both Sql Server and PostgreSQL. I can not seem to find a common expression that is basically select * from table where booleancol=false on SQL Server I must do(which is very confusing because the default value for bit types must be true or false, but you can't assign them to true or false or test against it) select * from table where booleancol=0 on PostgreSQL I must do select * from table where booleancol is false There are quite a lot of queries in our program that does this, so I'd prefer if there was just some universal syntax I

Standard SQL alternative to Oracle DECODE

£可爱£侵袭症+ 提交于 2019-12-03 20:01:53
问题 Is there an ANSI SQL equivalent to Oracle's DECODE function? Oracle's decode function is the IF-THEN-ELSE construct in SQL. 回答1: A CASE expression is the ANSI SQL method, of which there are 2 varieties, "simple" and "searched": 1) Simple CASE expression: CASE col WHEN 1 THEN 'One' WHEN 2 THEN 'Two' ELSE 'More' END 2) Searched CASE expression: CASE WHEN col < 0 THEN 'Negative' WHEN col = 0 THEN 'Zero' ELSE 'Positive' END 回答2: CASE WHEN a=1 THEN value1 WHEN a=2 THEN value2 ELSE default END SQL

Database Engines and ANSI SQL Compliance

北城余情 提交于 2019-12-03 18:59:04
问题 I've been searching for half an hour and can't find any resources stating what level of the SQL ANSI standard is supported on various database engines. It looks like some level of support is provided by most engines, but I'd like to know exactly what level is officially supported. I'm primarily interested in MySQL, PostgreSQL, SQL Server, and Oracle. EDIT: PostgreSQL has a great page on compliance, exactly what I was looking for regarding the other engines: http://www.postgresql.org/docs