想做一个简单的查询,请大家帮帮忙

MySql 码拜 8年前 (2016-07-12) 903次浏览
SELECT
orders.orders_id,
orders.delivery_name,
orders.delivery_company,
orders.delivery_street_address,
orders.delivery_suburb,
orders.delivery_city,
orders.delivery_postcode,
orders.delivery_state,
orders.delivery_country,
orders. customers_telephone,
orders.shipping_method,
orders_products.products_name,
orders_products.products_model,
orders_products_attributes.products_options_values
FROM `orders_products`, `orders`,`orders_products_attributes` where orders.orders_id = orders_products.orders_id = orders_products_attributes.orders_id and orders.orders_status = 2
本人是个纯新手,这个查询老是提示错误,不晓得应该怎么写才对呢?
解决方案

4

错误提示是什么? 贴出这样别人可以更快速的定位问题,而不需要再逐行分析题主的语句。

20

SELECT 
orders.orders_id,
orders.delivery_name,
orders.delivery_company,
orders.delivery_street_address,
orders.delivery_suburb,
orders.delivery_city,
orders.delivery_postcode,
orders.delivery_state,
orders.delivery_country,
orders. customers_telephone,
orders.shipping_method,
orders_products.products_name,
orders_products.products_model,
orders_products_attributes.products_options_values
FROM `orders_products`, `orders`,`orders_products_attributes` 
where  orders.orders_id = orders_products.orders_id
    and  orders.orders_id = orders_products_attributes.orders_id 
    and orders.orders_status = 2

貌似等于不能这么连着用吧。

4

FROM `orders_products`, `orders`,`orders_products_attributes`
where orders.orders_id = orders_products.orders_id = orders_products_attributes.orders_id and orders.orders_status = 2
红色的部分是错误的,sql语法不支持这种 a = b = c的操作,只能写出: a = b and b = c

4

的确,3楼正解,SQL语法中没有a = b = c这个语句,要表达这个意思只能用a = b and b = c

4

 orders.orders_id = orders_products.orders_id = orders_products_attributes.orders_id
这里怎么有连续2个=号呢?

4

1:将错误贴出来看下
2:where 后面不支持连续等号。可以看3楼

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明想做一个简单的查询,请大家帮帮忙
喜欢 (0)
[1034331897@qq.com]
分享 (0)