我对 MySQL 语句有疑问。
我有这个:
SELECT ad.*,
(SELECT img.image
FROM '.$this->config->db_prefix.'_images AS img
WHERE img.aid = ad.aid LIMIT 1) AS img
FROM '.$this->config->db_prefix.'_adverts ad
WHERE fid = :fid
ORDER BY cr_date DESC
哪个工作正常,但我需要从_images
表中获取所有图像,所以如果我删除LIMIT 1
我得到
Cardinality violation: 1242 Subquery returns more than 1 row
SQL 的结果以 JSON 格式输出。