|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Comma operator in FROM clause - what is this?I know how it functions, but what does this mean exactly, and where can
I find it in the books online? SELECT * FROM Table1, Table2 What is the name of that Comma's function? Thanks, Jeremy Most often, this is what we consider an old style join, which you forgot to restrict. Old style
join, as in SELECT ... FROM titles AS t, publishers AS p WHERE t.pub_id = p.pub_id Above is the same query as: SELECT ... FROM titles AS t JOIN publishers AS p ON t.pub_id = p.pub_id No, if you remove the WHERE clause from the first query, you get all rows from titles, combined with all rows from publihers. In most cases, a meaningless result. We call this cartesian product, cross join or unrestricted join. You can accomplish this using the new join syntax as: SELECT ... FROM titles AS t CROSS JOIN publishers AS p -- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ "Jeremy Cowles" <jeremy.cow***@gmail.com> wrote in message news:1134662287.068773.293050@g49g2000cwa.googlegroups.com... >I know how it functions, but what does this mean exactly, and where can > I find it in the books online? > > SELECT * > FROM Table1, Table2 > > > What is the name of that Comma's function? > > Thanks, > Jeremy > The comma is simply a delimiter. In your from clause you can list all the
tables/views/in line views you are accessing, seperated by commas, then define your join criteria in the where clause. If you have no join criteria then the result is a cartesion product (every row in table 1 is joined with every row in table 2). Show quote "Jeremy Cowles" <jeremy.cow***@gmail.com> wrote in message news:1134662287.068773.293050@g49g2000cwa.googlegroups.com... > I know how it functions, but what does this mean exactly, and where can > I find it in the books online? > > SELECT * > FROM Table1, Table2 > > > What is the name of that Comma's function? > > Thanks, > Jeremy > |
|||||||||||||||||||||||