david@intel-compute-stick:/var/www/html/039$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2248
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 test040;
Query OK, 1 row affected (0.038 sec)
MariaDB [(none)]> USE test040;
Database changed
MariaDB [test040]> CREATE TABLE abc (name1 VARCHAR (32), name2 VARCHAR (32));
Query OK, 0 rows affected (0.069 sec)
MariaDB [test040]> CREATE TABLE def (name3 VARCHAR (32), name4 VARCHAR (32));
Query OK, 0 rows affected (0.060 sec)
MariaDB [test040]> INSERT INTO abc VALUE ("001", "001");
Query OK, 1 row affected (0.031 sec)
MariaDB [test040]> INSERT INOT abc VALUES ("001", "002");
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 'abc VALUES ("001", "002")' at line 1
MariaDB [test040]> INSERT INTO abc VALUES ("001", "002");
Query OK, 1 row affected (0.030 sec)
MariaDB [test040]> SELECT * FROM abc;
+-------+-------+
| name1 | name2 |
+-------+-------+
| 001 | 001 |
| 001 | 002 |
+-------+-------+
2 rows in set (0.001 sec)
MariaDB [test040]> INSERT INTO abc VALUES ("002", "001");
Query OK, 1 row affected (0.030 sec)
MariaDB [test040]> INSERT INTO abc VALUES ("002", "002");
Query OK, 1 row affected (0.025 sec)
MariaDB [test040]> INSERT INTO def (name1, name3) VALUES ("001", "001");
ERROR 1054 (42S22): Unknown column 'name1' in 'field list'
MariaDB [test040]> INSERT INTO def (name3, name4) VALUES ("001", "001");
Query OK, 1 row affected (0.030 sec)
MariaDB [test040]> INSERT INTO def (name4, name3) VALUES ("002", "001");
Query OK, 1 row affected (0.027 sec)
MariaDB [test040]> INSERT INTO def (name3, name4) VALUES ("abc", "def");
Query OK, 1 row affected (0.027 sec)
MariaDB [test040]> SELECT * FROM abc;
+-------+-------+
| name1 | name2 |
+-------+-------+
| 001 | 001 |
| 001 | 002 |
| 002 | 001 |
| 002 | 002 |
+-------+-------+
4 rows in set (0.001 sec)
MariaDB [test040]> SELECT * FROM def;
+-------+-------+
| name3 | name4 |
+-------+-------+
| 001 | 001 |
| 001 | 002 |
| abc | def |
+-------+-------+
3 rows in set (0.001 sec)
MariaDB [test040]> SELECT * FROM abc JOIN def;
+-------+-------+-------+-------+
| name1 | name2 | name3 | name4 |
+-------+-------+-------+-------+
| 001 | 001 | 001 | 001 |
| 001 | 001 | 001 | 002 |
| 001 | 001 | abc | def |
| 001 | 002 | 001 | 001 |
| 001 | 002 | 001 | 002 |
| 001 | 002 | abc | def |
| 002 | 001 | 001 | 001 |
| 002 | 001 | 001 | 002 |
| 002 | 001 | abc | def |
| 002 | 002 | 001 | 001 |
| 002 | 002 | 001 | 002 |
| 002 | 002 | abc | def |
+-------+-------+-------+-------+
12 rows in set (0.002 sec)
MariaDB [test040]> SELECT * FROm abc INNER JOIN def.name3 = abc.name1;
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 '.name1' at line 1
MariaDB [test040]> SELECT * FROM abc INNER JOIN def.name3 = abc.name1;
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 '.name1' at line 1
MariaDB [test040]> SELECT * FROM abc INNER JOIN ON def.name3 = abc.name1;
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 'ON def.name3 = abc.name1' at line 1
MariaDB [test040]> SELECT * FROM abc INNER JOIN def OON def.name3 = abc.name1;
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 'def.name3 = abc.name1' at line 1
MariaDB [test040]> SELECT * FROM abc INNER JOIN def ON def.name3 = abc.name1;
+-------+-------+-------+-------+
| name1 | name2 | name3 | name4 |
+-------+-------+-------+-------+
| 001 | 001 | 001 | 001 |
| 001 | 001 | 001 | 002 |
| 001 | 002 | 001 | 001 |
| 001 | 002 | 001 | 002 |
+-------+-------+-------+-------+
4 rows in set (0.002 sec)
MariaDB [test040]> SELECT * FROM abc LEFT JOIN def ON abc.name1 = def.name3;
+-------+-------+-------+-------+
| name1 | name2 | name3 | name4 |
+-------+-------+-------+-------+
| 001 | 001 | 001 | 001 |
| 001 | 002 | 001 | 001 |
| 001 | 001 | 001 | 002 |
| 001 | 002 | 001 | 002 |
| 002 | 001 | NULL | NULL |
| 002 | 002 | NULL | NULL |
+-------+-------+-------+-------+
6 rows in set (0.002 sec)
MariaDB [test040]> SELECT * FROM abc RIGHT JOIN def ON abc.name2 = def.name4;
+-------+-------+-------+-------+
| name1 | name2 | name3 | name4 |
+-------+-------+-------+-------+
| 001 | 001 | 001 | 001 |
| 001 | 002 | 001 | 002 |
| 002 | 001 | 001 | 001 |
| 002 | 002 | 001 | 002 |
| NULL | NULL | abc | def |
+-------+-------+-------+-------+
5 rows in set (0.002 sec)
MariaDB [test040]> QUIT
Bye
david@intel-compute-stick:/var/www/html/039$