Dino Geek, try to help you

How to join two tables in MariaDB?


You join two tables in MariaDB using the SQL JOIN statement. Here is a basic JOIN example between two tables:

Let’s consider we have two tables:

1. `employees` table:

id name title
—— ———- ————
1 Bob Engineer
2 Alice Designer
3 Tom Manager

1. `dept` table:

id department
—— ——————
1 IT
2 PR
3 HR

If you want to join these two tables by ID, you can use the following SQL statement:

```
SELECT employees.name, employees.title, dept.department
FROM employees
INNER JOIN dept ON employees.id = dept.id;
```

This will give you a result like this:

name title department
———- ————— ——————
Bob Engineer IT
Alice Designer PR
Tom Manager HR

In this example, `INNER JOIN` returns only the records where there is a match in both the `employees` and `dept` table.

There are different types of SQL JOINs:
- (INNER) JOIN: Returns records that have matching values in both tables
- LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
- RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
- FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table

Please, replace the `INNER JOIN` keyword with `LEFT JOIN`, `RIGHT JOIN` or `FULL JOIN` if you need other types of joins.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use