English 中文(简体)
何时使用LQ,而不是加入?
原标题:When to use SQL natural join instead of join .. on?
  • 时间:2012-05-09 06:40:24
  •  标签:
  • sql

I mm在数据库考试中学习,而IQ ve 看到的方法是,它在这个网页上看到:

http://en.wikipedia.org/wiki/Star_schema IE join written the way Join <table name> On <table attribute> and then the join condition for the selection. My course book and my exercises given to me from the academic institution however, use only natural join in their examples. So when is it right to use natural join? Should natural join be used if the query can also be written using JOIN .. ON ?

Thanks for any answer or comment

最佳回答

天然的结合将发现两个表格中以相同名称的栏目,并增加每张楼梯的栏目。 内部人员同你一道,请具体说明你想要利用任何一栏进行对比。

问题回答

海事组织,日本国家税务局比自然加入海合会更可读、更可维持。 自然结合是一些旧标准遗留下来的,我试图避免它像 plague一样。

天然的结合将发现两个表格中以相同名称的栏目,并增加每张楼梯的栏目。 内部人员同你一道,请具体说明你想要利用任何一栏进行对比。

根据这些表格中的某些栏目之间的关系,JOIN的关键词在一份“Q”表中用于查询两个或两个以上表格的数据。

差异

*  JOIN: Return rows when there is at least one match in both tables
* LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
* RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
* FULL JOIN: Return rows when there is a match in one of the tables

INNER JOIN http://www.w3schools.com/sql/sql_join_inner.asp

FULL JOIN http://www.w3schools.com/sql/sql_join_full.asp

据说,自然结合是一种污染,因为它不允许对关键一栏进行限定,从而造成混淆。 因为你从未知道,“通勤”一栏正被用来仅仅通过审查面纱来加入两个表格。

北美国家航空航天研究所对各表之间任何共享的栏目进行对比,而国家自然资源研究所仅对特定国家情况进行匹配。

合并往往可以互换,结果通常相同。 然而,有一些重要的考虑:

  • If a NATURAL JOIN finds no matching columns, it returns the cross product. This could produce disastrous results if the schema is modified. On the other hand, an INNER JOIN will return a column does not exist error. This is much more fault tolerant.

  • An INNER JOIN self-documents with its ON clause, resulting in a clearer query that describes the table schema to the reader.

  • An INNER JOIN results in a maintainable and reusable query in which the column names can be swapped in and out with changes in the use case or table schema.

  • 节目设计员如果被迫确定国家定位,可提前注明姓名不匹配(例如,项目_ID诉项目ID)。

否则,全国住户抽样调查仍是一个快速、临时的选项。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签