Need to retrieve information from 2 tables that are not related on a sql db. Basically I need to view the name, salary AND salary_grade, according to lower_bound or upper_bound.
table A:
Table B:
For example John has a salary of $1000
{salary_grade, lower bound, upper bound}: {1, 800, 999}, {2, 1000, 1200} ...
so this view would bring fields "John" + "1000" + "2". As you see there is no foreign key or way to relate both tables and i'm struggling to find out a function to relate em.
Simply write a join using BETWEEN:
SELECT a.name, a.salary, b.salary_grade
FROM a JOIN b
ON a.salary BETWEEN b.lower_bound AND b.upper_bound
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.