0

我想我正在接近这个,但遇到了另一个障碍,不知道如何解决它

这个查询有什么问题 - 只是得到通用的“你有一个错误”,它指向连接,但我不知道如何修复它。我想要在 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`;
4

1 回答 1

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。

其次,你有一个 çaev 它有一个 unicode 字符。我不知道这是不是故意的。

可能这会起作用:

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”,只是为了使您的代码保持一致。

于 2013-08-09T17:12:53.887 回答