david@intel-compute-stick:~$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 832
Server version: 10.5.12-MariaDB-0+deb11u1 Debian 11
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE test014;
Query OK, 1 row affected (0.028 sec)
MariaDB [(none)]> USE test014;
Database changed
MariaDB [test014]> CREATE TABLE abc (abc01 VARCHAR (32), abc02 VARCHAR (32))
-> ;
Query OK, 0 rows affected (0.076 sec)
MariaDB [test014]> CREATE TABLE def (def01 VARCHAR (32), def02 VARCHAR (32));
Query OK, 0 rows affected (0.077 sec)
MariaDB [test014]> INSERT INTO abc VALUES ("001", "002");
Query OK, 1 row affected (0.040 sec)
MariaDB [test014]> INSERT INTO abc VALUES ("003", "004");
Query OK, 1 row affected (0.033 sec)
MariaDB [test014]> INSERT INTO abc VALUES ("001", "003");
Query OK, 1 row affected (0.028 sec)
MariaDB [test014]> INSERT INTO abc VALUES ("002", "004");
Query OK, 1 row affected (0.029 sec)
MariaDB [test014]> INSERT INTO def VALUES ("001", "002");
Query OK, 1 row affected (0.036 sec)
MariaDB [test014]> INSERT INTO def VALUES ("003", "004");
Query OK, 1 row affected (0.031 sec)
MariaDB [test014]> INSERT INTO def VALUES ("abc", "def");
Query OK, 1 row affected (0.026 sec)
MariaDB [test014]> INSERT INTO def VALUES ("ijk", "xyz");
Query OK, 1 row affected (0.030 sec)
MariaDB [test014]> SELECT * FROM abc;
+-------+-------+
| abc01 | abc02 |
+-------+-------+
| 001 | 002 |
| 003 | 004 |
| 001 | 003 |
| 002 | 004 |
+-------+-------+
4 rows in set (0.001 sec)
MariaDB [test014]> SELECT * FROM def;
+-------+-------+
| def01 | def02 |
+-------+-------+
| 001 | 002 |
| 003 | 004 |
| abc | def |
| ijk | xyz |
+-------+-------+
4 rows in set (0.001 sec)
MariaDB [test014]> SELECT * FROM abc WHERE abc01 = "001";
+-------+-------+
| abc01 | abc02 |
+-------+-------+
| 001 | 002 |
| 001 | 003 |
+-------+-------+
2 rows in set (0.027 sec)
MariaDB [test014]> SELECT * FROM abc JOIN DEF;
ERROR 1146 (42S02): Table 'test014.DEF' doesn't exist
MariaDB [test014]> SELECT * FROM abc JOIN def;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 003 | 004 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 002 | 004 | 001 | 002 |
| 001 | 002 | 003 | 004 |
| 003 | 004 | 003 | 004 |
| 001 | 003 | 003 | 004 |
| 002 | 004 | 003 | 004 |
| 001 | 002 | abc | def |
| 003 | 004 | abc | def |
| 001 | 003 | abc | def |
| 002 | 004 | abc | def |
| 001 | 002 | ijk | xyz |
| 003 | 004 | ijk | xyz |
| 001 | 003 | ijk | xyz |
| 002 | 004 | ijk | xyz |
+-------+-------+-------+-------+
16 rows in set (0.001 sec)
MariaDB [test014]> SELECT * FROM abc INNER JOIN abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.def01' at line 1
MariaDB [test014]> SELECT * FROM abc INNER JOIN WHERE abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE abc.abc01 = def.def01' at line 1
MariaDB [test014]> SELECT * FROM abc INNER JOIN def WHERE abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 003 | 004 | 003 | 004 |
+-------+-------+-------+-------+
3 rows in set (0.031 sec)
MariaDB [test014]> SELECT * FROM abc INNER JOIN def abc.abc01 = def.def01;
ERROR 1066 (42000): Not unique table/alias: 'abc'
MariaDB [test014]> SELECT * FROM abc INNER JOIN def WHERE abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 003 | 004 | 003 | 004 |
+-------+-------+-------+-------+
3 rows in set (0.002 sec)
MariaDB [test014]> SELECT * FROM abc LEFT JOIN def WHERE abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE abc.abc01 = def.def01' at line 1
MariaDB [test014]> SELECT * FROM abc RIGHT JOIN def WHERE abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE abc.abc01 = def.def01' at line 1
MariaDB [test014]> SELECT * FROM abc INNER JOIN def WHERE abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 003 | 004 | 003 | 004 |
+-------+-------+-------+-------+
3 rows in set (0.002 sec)
MariaDB [test014]> SELECT * FROM abc JOIN RIGHT def WHERE abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RIGHT def WHERE abc.abc01 = def.def01' at line 1
MariaDB [test014]> SELECT * FROM abc JOIN RIGHT def;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RIGHT def' at line 1
MariaDB [test014]> SELECT * FROM abc RIGHT JOIN def;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
MariaDB [test014]> SELECT * FROM abc JOIN RIGHT def ON abc.abc01 = def.def01;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RIGHT def ON abc.abc01 = def.def01' at line 1
MariaDB [test014]> SELECT * FROM abc RIGHT JOIN def ON abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 003 | 004 | 003 | 004 |
| 001 | 003 | 001 | 002 |
| NULL | NULL | abc | def |
| NULL | NULL | ijk | xyz |
+-------+-------+-------+-------+
5 rows in set (0.027 sec)
MariaDB [test014]> SELECT * FROM abc LEFT JOIN def ON abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 003 | 004 | 003 | 004 |
| 002 | 004 | NULL | NULL |
+-------+-------+-------+-------+
4 rows in set (0.002 sec)
MariaDB [test014]> SELECT * FROM abc INNER JOIN def ON abc.abc01 = def.def01;
+-------+-------+-------+-------+
| abc01 | abc02 | def01 | def02 |
+-------+-------+-------+-------+
| 001 | 002 | 001 | 002 |
| 001 | 003 | 001 | 002 |
| 003 | 004 | 003 | 004 |
+-------+-------+-------+-------+
3 rows in set (0.002 sec)
MariaDB [test014]> QUIT;
Bye
david@intel-compute-stick:~$