SQL中的括号是什么意思? SELECT
distinct
{shipment_requests.*},
{shippingaddress.*},
{billingaddress.*},
{orders.*},
{rep_infos.*},
{warehouses.*}
FROM warehouses
INNER JOIN
( select top 100 *
from shipment_requests
where warehouse_id=5 and shipment_requests.status_code='ready_to_ship')
shipment_requests
ON warehouses.id = shipment_requests.warehouse_id
INNER JOIN shipment_request_line_items
ON shipment_requests.id = shipment_request_line_items.shipment_request_id
这里面的(select top 。。。)什么意思? ------最佳解决方案-------------------- 不行,这是里面的子查询的名字 ,可以改名字 比如A 但是必须要有。 ------其他解决方案-------------------- 子查询: shipment_requests 表里前100行 ------其他解决方案-------------------- 把那个查询语句返回的结果集作为一个表来使用。里面的意思是查询满足条件的所有数据根据order by后的字段取出前一百行数据 ------其他解决方案-------------------- 查询前100行数据 ------其他解决方案--------------------
那么 ( select top 100 *
from shipment_requests
where warehouse_id=5 and shipment_requests.status_code='ready_to_ship')
shipment_requests 这个shipment_requests是否可以不要? ------其他解决方案--------------------
也就是说可以改成这样?
( select top 100 *
from shipment_requests
where warehouse_id=5 and shipment_requests.status_code='ready_to_ship')
A
ON warehouses.id = A.warehouse_id
INNER JOIN shipment_request_line_items
ON A.id = shipment_request_line_items.shipment_request_id