Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL查找/连接值范围内的一个值_Sql_Ms Access - Fatal编程技术网

SQL查找/连接值范围内的一个值

SQL查找/连接值范围内的一个值,sql,ms-access,Sql,Ms Access,这些是我的桌子。我想使用一个查询组合前两个表以获得如下所示的第三个表 本着学习SQL的精神,尝试以下方法: SELECT * FROM rates JOIN shipments ON (weight >= floor); 这并不能让你一路找到正确的答案,但我认为这说明了你可以如何做到这一点。本着学习SQL的精神,尝试以下方法: SELECT * FROM rates JOIN shipments ON (weight >= floor); 这并不能让你一路找到正确的答案,但我认为

这些是我的桌子。我想使用一个查询组合前两个表以获得如下所示的第三个表
本着学习SQL的精神,尝试以下方法:

SELECT * FROM rates JOIN shipments ON (weight >= floor);

这并不能让你一路找到正确的答案,但我认为这说明了你可以如何做到这一点。

本着学习SQL的精神,尝试以下方法:

SELECT * FROM rates JOIN shipments ON (weight >= floor);

这并不能让你一路找到正确的答案,但我认为这说明了你如何才能找到正确的答案。

下面的查询应该会让你得到所需的结果

SELECT s.shipmentid, s.weight, r.floor, r.ceiling, r.rate 
FROM rates r 
JOIN shipments s ON s.weight <= r.ceiling and s.weight >= floor
选择s.shipmentid、s.weight、r.floor、r.天花、r.rate
从r
在s.weight=地板上连接s

下面的查询应该会得到所需的结果

SELECT s.shipmentid, s.weight, r.floor, r.ceiling, r.rate 
FROM rates r 
JOIN shipments s ON s.weight <= r.ceiling and s.weight >= floor
选择s.shipmentid、s.weight、r.floor、r.天花、r.rate
从r
在s.weight=地板上连接s
试试这个:

select
  shipments.*, 
  (select floor from rates where shipments.weight between rates.floor and rates.ceiling) as floor,
  (select ceiling from rates where shipments.weight between rates.floor and rates.ceiling) as ceiling,
  (select rate from rates where shipments.weight between rates.floor and rates.ceiling) as rate
from shipments
我已经在Access 2013上对此进行了测试。

尝试一下:

select
  shipments.*, 
  (select floor from rates where shipments.weight between rates.floor and rates.ceiling) as floor,
  (select ceiling from rates where shipments.weight between rates.floor and rates.ceiling) as ceiling,
  (select rate from rates where shipments.weight between rates.floor and rates.ceiling) as rate
from shipments

我已经在Access 2013上对此进行了测试。

在MS Access中,我认为正确的语法是:

SELECT s.shipmentid, s.weight, r.floor, r.ceiling, r.rate 
FROM shipments as s LEFT JOIN
     rates as r 
     ON s.weight >= r.floor AND s.weight <= r.ceiling;
选择s.shipmentid、s.weight、r.floor、r.天花、r.rate
从装运到s左连接
费率为r

对于MS Access中的s.weight>=r.floor和s.weight,我认为正确的语法是:

SELECT s.shipmentid, s.weight, r.floor, r.ceiling, r.rate 
FROM shipments as s LEFT JOIN
     rates as r 
     ON s.weight >= r.floor AND s.weight <= r.ceiling;
选择s.shipmentid、s.weight、r.floor、r.天花、r.rate
从装运到s左连接
费率为r

在s.weight>=r.floor和s.weight Bhanu上,当您觉得某个解决方案满足您的需求时,请将您选择的回答标记为答案,结束您的问题。Bhanu,当您觉得某个解决方案满足您的需求时,请将您选择的回答标记为答案,结束您的问题。