How do I fix the join in this query

后端 未结 1 858
生来不讨喜
生来不讨喜 2021-01-26 17:49

I think I am closing in on this one, but ran into another snag and have no idea how to fix it

What is wrong with this query - just get the generic \"you have an error\",

相关标签:
1条回答
  • 2021-01-26 18:50

    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
    

    It is obvious that you have the JOIN before the FROM.

    Secondly, you have a çaev which has a unicode character. I don't know if this is intended.

    Probably this will work:

    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
    

    I have added an 'as' next to the 'two' allias only to make your code consistent.

    0 讨论(0)
提交回复
热议问题