Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Mysql Cross Join Statement 
 

Mysql Cross Join Statement is used to return the product of rows or records from both table.

 

Mysql Cross Join Statement

                         

Mysql Cross Join Statement is used to return the product of rows or records from both table.

Understand with Example 

The Tutorial illustrate an example from 'Mysql Cross Join Statement '. To understand this example we create a table roseindia. The create table construct a table 'roseindia' with required fieldname and data type.

 

 

 

 

Query to Create Table named roseindia:-

mysql> create table roseindia(Empid int,firstname varchar(30));
Query OK, 0 rows affected (0.05 sec)

Query to insert data into Table named roseindia:-

The insert into is used to add the records or rows into the table 'roseindia'.

mysql>  insert into roseindia values(01,'Girish');
Query OK, 1 row affected (0.02 sec)

mysql>  insert into roseindia values(02,'Komal');
Query OK, 1 row affected (0.00 sec)

mysql>  insert into roseindia values(03,'Amit');
Query OK, 1 row affected (0.02 sec)

mysql>  insert into roseindia values(04,'Sandeep');
Query OK, 1 row affected (0.03 sec)

Query to view data of  Table named roseindia:-

mysql> select * from roseindia;

Output:-

+-------+-----------+
| Empid | firstname |
+-------+-----------+
|     1 | Girish    |
|     2 | Komal     |
|     3 | Amit      |
|     4 | Sandeep   |
+-------+-----------+
4 rows in set (0.00 sec)

Query to Create Table newstrack:-

Now we create another table newstrack .The create table is used to create a table newstrack with field name and datatypes. 

mysql> create table newstrack(Empid int, lastname varchar(30));
Query OK, 0 rows affected (0.03 sec)

Query to insert data into Table named newstrack:-

Insert into add the records or rows into the table 'newstrack'.

mysql>  insert into newstrack values(01,'Suman');
Query OK, 1 row affected (0.02 sec)

mysql>  insert into newstrack values(02,'Ravi');
Query OK, 1 row affected (0.01 sec)

mysql>  insert into newstrack values(03,'Santosh');
Query OK, 1 row affected (0.01 sec)

mysql>  insert into newstrack values(04,'Vinod');
Query OK, 1 row affected (0.03 sec)

Query to view data of  Table named newstrack:-

mysql> select * from newstrack;

Output:-

+-------+-----------+
| Empid | firstname |
+-------+-----------+
|     1 | Suman     |
|     2 | Ravi      |
|     3 | Santosh   |
|     4 | Vinod     |
+-------+-----------+
4 rows in set (0.00 sec)

Query to join the data of the above two tables named roseindia and newstrack using crossjoin:-

The below query return you all the records or rows from both table name roseindia and newstrack.

mysql> select * from roseindia cross join newstrack order by roseindia.empid;

Output:-

+-------+-----------+-------+-----------+
| Empid | firstname | Empid | firstname |
+-------+-----------+-------+-----------+
|     1 | Girish    |     1 | Suman     |
|     1 | Girish    |     4 | Vinod     |
|     1 | Girish    |     3 | Santosh   |
|     1 | Girish    |     2 | Ravi      |
|     2 | Komal     |     2 | Ravi      |
|     2 | Komal     |     1 | Suman     |
|     2 | Komal     |     4 | Vinod     |
|     2 | Komal     |     3 | Santosh   |
|     3 | Amit      |     3 | Santosh   |
|     3 | Amit      |     2 | Ravi      |
|     3 | Amit      |     1 | Suman     |
|     3 | Amit      |     4 | Vinod     |
|     4 | Sandeep   |     4 | Vinod     |
|     4 | Sandeep   |     3 | Santosh   |
|     4 | Sandeep   |     2 | Ravi      |
|     4 | Sandeep   |     1 | Suman     |
+-------+-----------+-------+-----------+
16 rows in set (0.00 sec)

                         

» View all related tutorials
Related Tags: sql mysql c com table ui join io tables column compare name columns tab joins nat specialization ci bot e

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.