Home All Groups Group Topic Archive Search About

Comma operator in FROM clause - what is this?

Author
15 Dec 2005 3:58 PM
Jeremy Cowles
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

Author
15 Dec 2005 4:29 PM
Tibor Karaszi
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 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
>
Author
15 Dec 2005 4:38 PM
Jeremy Cowles
Spanx!
Author
15 Dec 2005 4:38 PM
Jim Underwood
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
>

AddThis Social Bookmark Button