对ecshop系统做一些改造,需要一个三表join的查询,但写出语句却报错了
#1241 – Operand should contain 1 column(s)
语句如下:
SELECT a . * , IFNULL( g.goods_thumb, ” ) AS goods_thumb, g.goods_name AS goods_name_from_goods, g.brand_id, b.brand_name
FROM `eb`.`ec_goods_activity` AS a
LEFT JOIN (`eb`.`ec_goods` AS g , `eb`.`ec_brand` AS b )
ON (a.goods_id = g.goods_id , b.brand_id = g.brand_id)
WHERE a.act_type = ‘5’
AND a.start_time <= ‘1333010119’
AND a.end_time >= ‘1333010119’
AND a.is_finished <2
ORDER BY a.act_id DESC
LIMIT 20
起初死活找不到错误,突然发现ON子句里把条件and错写成逗号了,改正后执行正确,问题解决。
SELECT a. * , IFNULL( g.goods_thumb, ” ) AS goods_thumb, g.goods_name AS goods_name_from_goods, g.brand_id, b.brand_name
FROM `eb`.`ec_goods_activity` AS a
LEFT JOIN (
`eb`.`ec_goods` AS g, `eb`.`ec_brand` AS b
) ON ( a.goods_id = g.goods_id AND b.brand_id = g.brand_id )
WHERE a.act_type = ‘5’
AND a.start_time = ‘1333010119’
AND a.is_finished ORDER BY a.act_id DESC
LIMIT 20
评论关闭。