0

出于某种原因,以下查询中出现错误,它给出“FUNCTION j.CONCAT 不存在”当我删除 concat 并只输入 .price 没有问题,所以问题必须在 concat 中的某个地方...... sql 检索还从数据库中购买了物品。

SELECT k.productid_with             AS productid_with, 
   g.product                    AS product_with_product, 
   j.CONCAT('€ ', price)   AS productid_with_price, 
   Replace(o.image_path, 
   '/home/user/domains/domain.com/public_html', 
   'http://www.domain.com') AS productid_with_image, 
   Replace(l.image_path, 
   '/home/user/domains/domain.com/public_html', 
   'http://www.domain.com') AS productid_with_bigImage, 
   k.productid, 
   h.product, 
   i.CONCAT('€ ', price) AS price, 
   Replace(m.image_path, 
   '/home/user/domains/domain.com/public_html', 
   'http://www.domain.com') AS image, 
   Replace(n.image_path, 
   '/home/user/domains/domain.com/public_html', 
   'http://www.domain.com') AS bigImage 
FROM   xcart_also_bought k 
   JOIN xcart_products_categories c 
     ON c.productid = 8863 
   JOIN xcart_categories d 
     ON c.categoryid = d.categoryid 
        AND d.parentid = 0 
   JOIN xcart_products a 
     ON k.productid_with = a.productid 
        AND a.forsale = 'Y' 
   JOIN xcart_products_categories e 
     ON a.productid = e.productid 
        AND e.categoryid = d.categoryid 
   JOIN xcart_products_lng g 
     ON a.productid = g.productid 
   JOIN xcart_pricing j 
     ON a.productid = j.productid 
   JOIN xcart_thumbnails o 
     ON a.productid = o.productid 
   JOIN xcart_bigthumbnails l 
     ON a.productid = l.productid 
   JOIN xcart_products b 
     ON k.productid = b.productid 
        AND b.forsale = 'Y' 
   JOIN xcart_products_categories f 
     ON b.productid = f.productid 
        AND f.categoryid = d.categoryid 
   JOIN xcart_products_lng h 
     ON b.productid = h.productid 
   JOIN xcart_pricing i 
     ON b.productid = i.productid 
   JOIN xcart_thumbnails m 
     ON b.productid = m.productid 
   JOIN xcart_bigthumbnails n 
     ON b.productid = n.productid 
WHERE  ( k.productid = '8863' 
      OR k.productid_with = '8863' ) 
ORDER  BY bought DESC 
4

1 回答 1

3

请问可以这样用吗?

CONCAT('€ ', j.price)   AS productid_with_price, 

CONCAT('€ ', i.price) AS price, 

告诉你一个秘密:D MYSQL 没有j.CONCATi.CONCAT............它只有CONCAT

明确指出,您将表别名放在CONCAT函数上,因为您应该将它放在您的fields:)

于 2012-12-06T06:41:11.970 回答