Question:
How to do a cartesian product on these tables (SQL)?
?
2012-02-24 19:56:05 UTC
First off, forgive my ignorance, but please I need help with this SQL how do I join or get Cartesian product on the first two tables called prov and proy, and the last table is what I want to get:

http://www.flickr.com/photos/63259070@N06/6927438513/
Three answers:
PS
2012-02-26 22:30:51 UTC
The keyword Cross Join returns the Cartesian product of rows from tables in the join.

It combines each row from the first table with each row from the second table.



Example of a implicit cross join (the system percieves it as a cross join) is:

Select * from employee, department;



example of a explicit cross join (by explictly using the keyword) is:

Select * from employee CROSS JOIN department;



You can use any of the above ways to get the Cartesian product in MS SQL.



Good Luck.!
TheMadProfessor
2012-02-25 20:22:15 UTC
If you really want a Cartesian product of two or more tables, just do a select without any JOIN or WHERE relational criteria. (I don't know what you'd possibly use that for tho)
Serge M
2012-02-25 06:03:59 UTC
Cartesian product: http://www.sql-tutorial.ru/en/book_cartesian_product.html


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...