我认为我正在接近这个,但遇到另一个障碍,不知道如何解决它
这个查询出了什么问题 - 只是得到通用的“你有错误”,它指的是连接,但我不知道如何修复它。我想在customer_address_entity上加入,因为它有一个我需要在其中一个select语句中使用的唯一ID。
select c.*,
(
select caet.value
from customer_address_entity_test caet
where cae.entity_id = caet.value_id
and caet.attribute_id = 23
) as test,
(
select caev.value
from customer_address_entity_varchar caev
where caet.entity_id = caev.entity_id
and caev.attribute_id = 23
) as two
from customer_entity c where store_id = 15
join customer_address_entity cae on c.`entity_id` = cae.`parent_id`;
答案 0 :(得分:0)
首先,您的代码如下所示:
select c.*,
(
select caet.value
from customer_address_entity_test caet
where cae.entity_id = caet.value_id
and caet.attribute_id = 23
) as test,
(
select çaev.value
from customer_address_entity_varchar caev
where caet.entity_id = caev.entity_id
and caev.attribute_id = 23
) two
join customer_address_entity cae on c.`entity_id` = cae.`parent_id`
from customer_entity c where store_id = 8
显然你在FROM之前有JOIN。
其次,你有一个具有unicode字符的çaev。我不知道这是否有意。
可能会有效:
select c.*,
(
select caet.value
from customer_address_entity_test caet
where cae.entity_id = caet.value_id
and caet.attribute_id = 23
) as test,
(
select caev.value
from customer_address_entity_varchar caev
where caet.entity_id = caev.entity_id
and caev.attribute_id = 23
) as two
from customer_entity c
join customer_address_entity cae on c.`entity_id` = cae.`parent_id`
where store_id = 8
我在“两个”别名旁边添加了“as”,只是为了让您的代码保持一致。