Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Question 34: Connect the queries a-d to the resultsets 1-4 – MySQL Question of the Day

Skip to content

By urs in mysql questions

 

create table j1 (i int primary key);
create table j2 like j1;
 
insert into j1 values (1),(2),(3);
insert into j2 values (1),(2),(3);

 
Queries:
 

a) select * from j1,j2;
b) select * from j1,j2 where j1.i=j2.i;
c) select * from j1,j2 where j1.i<>j2.i;
d) select * from j1,j2 where j1.i>j2.i;

 
Results:
 

1)
+---+---+
| i | i |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
3 rows in set (0.00 sec)
 
2)
+---+---+
| i | i |
+---+---+
| 2 | 1 |
| 3 | 1 |
| 1 | 2 |
| 3 | 2 |
| 1 | 3 |
| 2 | 3 |
+---+---+
6 rows in set (0.00 sec)
 
3)
+---+---+
| i | i |
+---+---+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 1 | 2 |
| 2 | 2 |
| 3 | 2 |
| 1 | 3 |
| 2 | 3 |
| 3 | 3 |
+---+---+
9 rows in set (0.00 sec)
 
4)
+---+---+
| i | i |
+---+---+
| 2 | 1 |
| 3 | 1 |
| 3 | 2 |
+---+---+
3 rows in set (0.00 sec)

 
[ Joins (10%) - Overview ]
 

Tags: , ,

Comment Feed

One Response


  1.  
    Answers:
     
    a-3
    b-1
    c-2
    d-4
     

You must be logged in to post a comment.