SQL中的方括号怎么用? 本帖最后由 xulonghua1988219 于 2012-11-15 16:13:11 编辑
SELECT distinct [[shipment_requests.*]],[[shippingaddress.*]],[[billingaddress.*]],[[orders.*]],[[rep_infos.*]],[[warehouses.*]]
FROM warehouses INNER JOIN
(select top {2} * from shipment_requests where warehouse_id={0} and shipment_requests.status_code='{1}') 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 LEFT JOIN
comments ON shipment_requests.id=comments.shipment_request_id LEFT JOIN
orders ON shipment_requests.order_id = orders.id LEFT JOIN
order_line_items ON orders.id=order_line_items.order_id INNER JOIN
rep_infos ON shipment_requests.rep_info_id=rep_infos.id INNER JOIN
addresses shippingaddress ON shipment_requests.shipping_address_id = shippingaddress.id INNER JOIN
addresses billingaddress ON shipment_requests.billing_address_id = billingaddress.id
1、这里为什么用两层方括号?
2、我在一个C#程序里面读这个SQL语句,单步跟踪后,发现[...]变成了{...}这又是为什么?
3、(select top {2} * from shipment_requests where warehouse_id={0} and shipment_requests.status_code='{1}') shipment_requests 这里面shipment_requests 这块一直报错,是不是因为shipment_requests是表名了,所以不能再用这个名称了? ------最佳解决方案-------------------- []用过,{}没有过 ------其他解决方案-------------------- 绝大部分语言都存在关键字、保留字,这些如果不用[]来包住的话,不一定报错,但是很容易报错。 ------其他解决方案-------------------- 终于明白了,hibernate内部还会有替换。 ------其他解决方案--------------------