ansi-sql-92

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.

Insert into … values ( SELECT … FROM … )

落爺英雄遲暮 提交于 2019-11-25 21:42:19
问题 I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQL engine of the day (MySQL, Oracle, SQL Server, Informix, and DB2). Is there a silver-bullet syntax coming from an SQL standard (for example, SQL-92) that would allow me to insert the values without worrying about the underlying database? 回答1: Try: INSERT INTO table1 ( column1 ) SELECT col1 FROM