Detailed explanation of MySQL sql99 syntax inner join and non-equivalent join

Detailed explanation of MySQL sql99 syntax inner join and non-equivalent join

#Case: Query employee salary levels

SELECT
  salary,grade_level
FROM
  employees
JOIN
  job_grades g
ON
  e.`salary` BETWEEN g.`lowest_sal` AND g.`lowest_sal`;

#Example: Query the number of each salary level and sort by level in descending order

SELECT
  COUNT(*),grade_level
FROM
  job_grades j
JOIN
  employees
ON
  e.`salary` BETWEEN j.`lowest_sal` AND j.`highest_sal`
GROUP BY
  grade_level DESC;

Content extension :

grammar

select query list

from Table 1 Alias ​​[Connection Type]

jion Table 2 Alias

on connection condition

[where filter conditions]

[group by grouping]

[having filter conditions]

[order by sort list]

Case 1: Query employee name, department name

SELECT last_name,department_name
FROM employees
INNER JOIN departments d
ON e.department_id=d.department_id;

Case 2: Query the employee names and job titles containing "e" (add filter)

SELECT last_name,job_title
FROM employees
INNER JOIN jobs j
ON e.job_id=j.job_id
WHERE e.last_name LIKE '%e%';

The above is all the knowledge points introduced this time.

You may also be interested in:
  • Detailed explanation of MySQL database--multi-table query--inner join, outer join, subquery, correlated subquery
  • mysql join query (left join, right join, inner join)
  • MYSQL left join right join and inner join detailed explanation and difference
  • mysql left join, right join and inner join
  • Examples of using MySQL left and right inner joins
  • Briefly talk about mysql left join inner join
  • The difference between mysql outer join and inner join query

<<:  Vue custom instructions to achieve pop-up window drag four-side stretching and diagonal stretching effect

>>:  Linux tac command implementation example

Recommend

A brief talk about the diff algorithm in Vue

Table of contents Overview Virtual Dom principle ...

Summary of several MySQL installation methods and configuration issues

1. MySQL rpm package installation # Download the ...

Pure CSS header fixed implementation code

There are two main reasons why it is difficult to...

Detailed explanation of Linux command file overwrite and file append

1. The difference between the command > and &g...

Detailed explanation of character sets and validation rules in MySQL

1Several common character sets In MySQL, the most...

Understanding of haslaylout and bfc parsing

1. haslayout and bfc are IE-specific and standard ...

Example code for setting hot links and coordinate values ​​for web images

Sometimes you need to set several areas on a pict...

How to implement email alert in zabbix

Implemented according to the online tutorial. zab...

How to implement Nginx reverse proxy for multiple servers

Nginx reverse proxy multiple servers, which means...

Install nvidia graphics driver under Ubuntu (simple installation method)

Install the nvidia graphics card driver under Ubu...

JavaScript implements double-ended queue

This article example shares the specific code of ...

Query the data of the day before the current time interval in MySQL

1. Background In actual projects, we will encount...