Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Cross Join in SQL

Cross Join in SQL

? CROSS JOIN in SQL

A CROSS JOIN produces the Cartesian product of two tables, meaning it returns all possible combinations of rows from both tables.


? Syntax

SELECT *FROM table1CROSS JOIN table2;

? Example

Suppose you have two tables:

Colors

color
Red
Blue

Shapes

shape
Circle
Square

Query:

SELECT color, shapeFROM ColorsCROSS JOIN Shapes;

Result:

colorshape
RedCircle
RedSquare
BlueCircle
BlueSquare

? Notes

  • CROSS JOIN returns every combination of rows from both tables.

  • Number of rows in result = (rows in table1) × (rows in table2).

  • Often used when you want to combine every row from one table with every row from another.


If you want examples with other join types or filtering CROSS JOIN results, just ask!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql