# SQL CROSS JOIN

Consider the two tables below:

**Student**

![](/files/-LSfB3t8cnSB9mOdp9Ny)

**StudentCourse**

![](/files/-LSfBTMIaegoLhw6pI9X)

**CARTESIAN JOIN**: The CARTESIAN JOIN is also known as CROSS JOIN. In a CARTESIAN JOIN there is a join for each row of one table to every row of another table. This usually happens when the matching column or WHERE condition is not specified.

* In the absence of a WHERE condition the CARTESIAN JOIN will behave like a CARTESIAN PRODUCT . i.e., the number of rows in the result-set is the product of the number of rows of the two tables.
* In the presence of WHERE condition this JOIN will function like a INNER JOIN.
* Generally speaking, Cross join is similar to an inner join where the join-condition will always evaluate to True

**Syntax:**

```sql
SELECT table1.column1 , table1.column2, table2.column1...
FROM table1
CROSS JOIN table2;

table1: First table.
table2: Second table
```

**Example Queries (CARTESIAN JOIN):**

* In the below query we will select NAME and Age from Student table and COURSE\_ID from StudentCourse table. In the output you can see that each row of the table Student is joined with every row of the table StudentCourse. The total rows in the result-set = 4 \* 4 = 16.

  ```sql
  SELECT Student.NAME, Student.AGE, StudentCourse.COURSE_ID
  FROM Student
  CROSS JOIN StudentCourse;
  ```

**Output :**

![](/files/-LSfBrYH95Ss1fz2WTcN)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gyansetu-sql.gitbook.io/sql-programming/sql-select/sql-joins/sql-cross-join.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
