如何在此查询中修复联接 [英] How do I fix the join in this query
问题描述
我想我正在接近这个问题,但是遇到了另一个障碍并且不知道如何解决它
I think I am closing in on this one, but ran into another snag and have no idea how to fix it
此查询有什么问题-只是获得通用的您有一个错误",它指向联接,但我不知道如何解决.我想要对customer_address_entity进行联接,因为它具有我需要在其中一条select语句中使用的另一个唯一ID.
What is wrong with this query - just get the generic "you have an error", it is pointing to the join, but I don't know how to fix it. I want the join on the customer_address_entity because it has the other unique id that I need to use in one of the select statements.
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`;
推荐答案
首先,您的代码如下所示:
First of all your code looks like this:
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.
It is obvious that you have the JOIN before the FROM.
第二,您有一个带有unicode字符的çaev.我不知道这是否有意.
Secondly, you have a çaev which has a unicode character. I don't know if this is intended.
可能会起作用:
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",只是为了使您的代码一致.
I have added an 'as' next to the 'two' allias only to make your code consistent.
这篇关于如何在此查询中修复联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!