Book Image

MariaDb Essentials

Book Image

MariaDb Essentials

Overview of this book

This book will take you through all the nitty-gritty parts of MariaDB, right from the creation of your database all the way to using MariaDB’s advanced features. At the very beginning, we show you the basics, that is, how to install MariaDB. Then, we walk you through the databases and tables of MariaDB, and introduce SQL in MariaDB. You will learn about all the features that have been added in MariaDB but are absent in MySQL. Moving on, you’ll learn to import and export data, views, virtual columns, and dynamic columns in MariaDB. Then, you’ll get to grips with full-text searches and queries in MariaDb. You’ll also be familiarized with the CONNECT storage engine. At the end of the book, you’ll be introduced to the community of MariaDB.
Table of Contents (15 chapters)
MariaDB Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Joining tables


While examining the GROUP BY clause, we joined two tables into one resultset. This is a common operation when working with relational databases, because a table is generally correlated with other tables. The statement that allows us to do so is JOIN.

There are several types of joins:

  • CROSS JOIN

  • INNER JOIN

  • LEFT JOIN

  • RIGHT JOIN

The cross join operation

A CROSS JOIN is an operation that associates all the rows from the left table to all the rows in the right table. The number of rows in the resultset is the product of the number of rows in the left table multiplied by the number of rows in the second table, which is usually a huge number. This operation is very rarely used, and it is very expensive.

The following is an example of CROSS JOIN. Imagine we have two tables, both containing the numbers from 1 to 3:

MariaDB [test]> SELECT a.c, b.c FROM t1 a CROSS JOIN t2 b;
+------+------+
| c    | c    |
+------+------+
|    1 |    1 |
|    2 |    1 |
|    3 |    1 |
|    1 |  ...