Authors
select * from authors order by last, first
Export to Excel ( Row)
id first last
7 Douglas Adams
1 Isaac Asimov
6 Roald Dahl
4 Charles Dickens
2 Robert Heinlein
8 mark56 iUTMUATUqCOKzq
3 Stanisław Lem
5 J. R. R. Tolkien


Books
select * from books order by title
Export to Excel ( Row)
id authorId title
9 4 David Copperfield
2 1 Foundation
1 1 Foundation & Empire
14 1 I, Robot
20 6 James and the Giant Peach
11 4 Nicholas Nickleby
13 4 Oliver Twist
34 3 Return from the Stars
5 1 Second Foundation
31 7 So Long, and Thanks for All the Fish
4 3 Solaris
3 2 Starship Troopers
23 6 Tales of the Unexpected
24 5 The Fellowship of the Ring
28 7 The Hitchhiker's Guide to the Galaxy
25 5 The Hobbit
15 2 The Number of the Beast


Join
select a.*, b.* from authors a, books b where a.id = b.authorId order by a.first, a.last, b.title
Export to Excel ( Row)
id first last authorId title
9 Charles Dickens 4 David Copperfield
11 Charles Dickens 4 Nicholas Nickleby
13 Charles Dickens 4 Oliver Twist
31 Douglas Adams 7 So Long, and Thanks for All the Fish
28 Douglas Adams 7 The Hitchhiker's Guide to the Galaxy
2 Isaac Asimov 1 Foundation
1 Isaac Asimov 1 Foundation & Empire
14 Isaac Asimov 1 I, Robot
5 Isaac Asimov 1 Second Foundation
24 J. R. R. Tolkien 5 The Fellowship of the Ring
25 J. R. R. Tolkien 5 The Hobbit
20 Roald Dahl 6 James and the Giant Peach
23 Roald Dahl 6 Tales of the Unexpected
3 Robert Heinlein 2 Starship Troopers
15 Robert Heinlein 2 The Number of the Beast
34 Stanisław Lem 3 Return from the Stars
4 Stanisław Lem 3 Solaris


Foundation
select a.first, a.last, b.title from authors a, books b where a.id = b.authorId and b.title like '%Foundation%' order by a.first, a.last, b.title
Export to Excel ( Row)
first last title
Isaac Asimov Foundation
Isaac Asimov Foundation & Empire
Isaac Asimov Second Foundation


The Complete Cartesian Product
select a.*, b.* from authors a, books b order by a.first, a.last, b.title
Export to Excel ( Row)
id first last authorId title
9 Charles Dickens 4 David Copperfield
2 Charles Dickens 1 Foundation
1 Charles Dickens 1 Foundation & Empire
14 Charles Dickens 1 I, Robot
20 Charles Dickens 6 James and the Giant Peach
11 Charles Dickens 4 Nicholas Nickleby
13 Charles Dickens 4 Oliver Twist
34 Charles Dickens 3 Return from the Stars
5 Charles Dickens 1 Second Foundation
31 Charles Dickens 7 So Long, and Thanks for All the Fish
4 Charles Dickens 3 Solaris
3 Charles Dickens 2 Starship Troopers
23 Charles Dickens 6 Tales of the Unexpected
24 Charles Dickens 5 The Fellowship of the Ring
28 Charles Dickens 7 The Hitchhiker's Guide to the Galaxy
25 Charles Dickens 5 The Hobbit
15 Charles Dickens 2 The Number of the Beast
9 Douglas Adams 4 David Copperfield
2 Douglas Adams 1 Foundation
1 Douglas Adams 1 Foundation & Empire
14 Douglas Adams 1 I, Robot
20 Douglas Adams 6 James and the Giant Peach
11 Douglas Adams 4 Nicholas Nickleby
13 Douglas Adams 4 Oliver Twist
34 Douglas Adams 3 Return from the Stars
5 Douglas Adams 1 Second Foundation
31 Douglas Adams 7 So Long, and Thanks for All the Fish
4 Douglas Adams 3 Solaris
3 Douglas Adams 2 Starship Troopers
23 Douglas Adams 6 Tales of the Unexpected
24 Douglas Adams 5 The Fellowship of the Ring
28 Douglas Adams 7 The Hitchhiker's Guide to the Galaxy
25 Douglas Adams 5 The Hobbit
15 Douglas Adams 2 The Number of the Beast
9 Isaac Asimov 4 David Copperfield
2 Isaac Asimov 1 Foundation
1 Isaac Asimov 1 Foundation & Empire
14 Isaac Asimov 1 I, Robot
20 Isaac Asimov 6 James and the Giant Peach
11 Isaac Asimov 4 Nicholas Nickleby
13 Isaac Asimov 4 Oliver Twist
34 Isaac Asimov 3 Return from the Stars
5 Isaac Asimov 1 Second Foundation
31 Isaac Asimov 7 So Long, and Thanks for All the Fish
4 Isaac Asimov 3 Solaris
3 Isaac Asimov 2 Starship Troopers
23 Isaac Asimov 6 Tales of the Unexpected
24 Isaac Asimov 5 The Fellowship of the Ring
28 Isaac Asimov 7 The Hitchhiker's Guide to the Galaxy
25 Isaac Asimov 5 The Hobbit
15 Isaac Asimov 2 The Number of the Beast
9 J. R. R. Tolkien 4 David Copperfield
2 J. R. R. Tolkien 1 Foundation
1 J. R. R. Tolkien 1 Foundation & Empire
14 J. R. R. Tolkien 1 I, Robot
20 J. R. R. Tolkien 6 James and the Giant Peach
11 J. R. R. Tolkien 4 Nicholas Nickleby
13 J. R. R. Tolkien 4 Oliver Twist
34 J. R. R. Tolkien 3 Return from the Stars
5 J. R. R. Tolkien 1 Second Foundation
31 J. R. R. Tolkien 7 So Long, and Thanks for All the Fish
4 J. R. R. Tolkien 3 Solaris
3 J. R. R. Tolkien 2 Starship Troopers
23 J. R. R. Tolkien 6 Tales of the Unexpected
24 J. R. R. Tolkien 5 The Fellowship of the Ring
28 J. R. R. Tolkien 7 The Hitchhiker's Guide to the Galaxy
25 J. R. R. Tolkien 5 The Hobbit
15 J. R. R. Tolkien 2 The Number of the Beast
9 mark56 iUTMUATUqCOKzq 4 David Copperfield
2 mark56 iUTMUATUqCOKzq 1 Foundation
1 mark56 iUTMUATUqCOKzq 1 Foundation & Empire
14 mark56 iUTMUATUqCOKzq 1 I, Robot
20 mark56 iUTMUATUqCOKzq 6 James and the Giant Peach
11 mark56 iUTMUATUqCOKzq 4 Nicholas Nickleby
13 mark56 iUTMUATUqCOKzq 4 Oliver Twist
34 mark56 iUTMUATUqCOKzq 3 Return from the Stars
5 mark56 iUTMUATUqCOKzq 1 Second Foundation
31 mark56 iUTMUATUqCOKzq 7 So Long, and Thanks for All the Fish
4 mark56 iUTMUATUqCOKzq 3 Solaris
3 mark56 iUTMUATUqCOKzq 2 Starship Troopers
23 mark56 iUTMUATUqCOKzq 6 Tales of the Unexpected
24 mark56 iUTMUATUqCOKzq 5 The Fellowship of the Ring
28 mark56 iUTMUATUqCOKzq 7 The Hitchhiker's Guide to the Galaxy
25 mark56 iUTMUATUqCOKzq 5 The Hobbit
15 mark56 iUTMUATUqCOKzq 2 The Number of the Beast
9 Roald Dahl 4 David Copperfield
2 Roald Dahl 1 Foundation
1 Roald Dahl 1 Foundation & Empire
14 Roald Dahl 1 I, Robot
20 Roald Dahl 6 James and the Giant Peach
11 Roald Dahl 4 Nicholas Nickleby
13 Roald Dahl 4 Oliver Twist
34 Roald Dahl 3 Return from the Stars
5 Roald Dahl 1 Second Foundation
31 Roald Dahl 7 So Long, and Thanks for All the Fish
4 Roald Dahl 3 Solaris
3 Roald Dahl 2 Starship Troopers
23 Roald Dahl 6 Tales of the Unexpected
24 Roald Dahl 5 The Fellowship of the Ring
28 Roald Dahl 7 The Hitchhiker's Guide to the Galaxy
25 Roald Dahl 5 The Hobbit
15 Roald Dahl 2 The Number of the Beast
9 Robert Heinlein 4 David Copperfield
2 Robert Heinlein 1 Foundation
1 Robert Heinlein 1 Foundation & Empire
14 Robert Heinlein 1 I, Robot
20 Robert Heinlein 6 James and the Giant Peach
11 Robert Heinlein 4 Nicholas Nickleby
13 Robert Heinlein 4 Oliver Twist
34 Robert Heinlein 3 Return from the Stars
5 Robert Heinlein 1 Second Foundation
31 Robert Heinlein 7 So Long, and Thanks for All the Fish
4 Robert Heinlein 3 Solaris
3 Robert Heinlein 2 Starship Troopers
23 Robert Heinlein 6 Tales of the Unexpected
24 Robert Heinlein 5 The Fellowship of the Ring
28 Robert Heinlein 7 The Hitchhiker's Guide to the Galaxy
25 Robert Heinlein 5 The Hobbit
15 Robert Heinlein 2 The Number of the Beast
9 Stanisław Lem 4 David Copperfield
2 Stanisław Lem 1 Foundation
1 Stanisław Lem 1 Foundation & Empire
14 Stanisław Lem 1 I, Robot
20 Stanisław Lem 6 James and the Giant Peach
11 Stanisław Lem 4 Nicholas Nickleby
13 Stanisław Lem 4 Oliver Twist
34 Stanisław Lem 3 Return from the Stars
5 Stanisław Lem 1 Second Foundation
31 Stanisław Lem 7 So Long, and Thanks for All the Fish
4 Stanisław Lem 3 Solaris
3 Stanisław Lem 2 Starship Troopers
23 Stanisław Lem 6 Tales of the Unexpected
24 Stanisław Lem 5 The Fellowship of the Ring
28 Stanisław Lem 7 The Hitchhiker's Guide to the Galaxy
25 Stanisław Lem 5 The Hobbit
15 Stanisław Lem 2 The Number of the Beast


Joins.class.php
<?php
/*------------------------------------------------------------*/
class Joins extends Mcontroller {
    
/*------------------------------------------------------------*/
    
public function index() {
        
$queries = array(
            array(
                
'title' => "Authors",
                
'sql' => "select * from authors order by last, first",
                
'exportFileName' => "Authors",
            ),
            array(
                
'title' => "Books",
                
'sql' => "select * from books order by title",
                
'exportFileName' => "Books",
            ),
            array(
                
'title' => "Join",
                
'sql' => "select a.*, b.* from authors a, books b where a.id = b.authorId order by a.first, a.last, b.title",
                
'exportFileName' => "BooksAndAuthors",
            ),
            array(
                
'title' => "Foundation",
                
'sql' => "select a.first, a.last, b.title from authors a, books b where a.id = b.authorId and b.title like '%Foundation%' order by a.first, a.last, b.title",
                
'exportFileName' => "Foundation",
            ),
            array(
                
'title' => "The Complete Cartesian Product",
                
'sql' => "select a.*, b.* from authors a, books b order by a.first, a.last, b.title",
                
'exportFileName' => "Cartesian",
            ),
        );
        foreach ( 
$queries as $query ) {
            
Mview::msg($query['title'], true);
            
Mview::msg($query['sql']);
            
$this->showRows($query['sql'], true$query['exportFileName']);
            echo 
"<br /><br />\n";
        }
        
$file "Joins.class.php";
        
Mview::msg($file);
        
highlight_file($file);
    }
    
/*------------------------------------------------------------*/
}
/*------------------------------------------------------------*/