我想找到一种方法将这两个表连接起来,这是我能够做到的,但是如果它发现多个匹配的值,它会再次显示产品表中的所有内容。现在我试图使用MySQL GROUP_CONCAT在一起,能够列出所有TNAME在一个领域的阵列中,但我不断收到一个错误与MySQL:CodeIgniter GROUP_CONCAT并加入
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM (
sp_product
) LEFT OUTER JOINsp_product_type
ONsp_product_type
.`tCat' at line 2SELECT
sp_product
.name
,sp_product
.price
,sp_product
.perm_name
,sp_product
.description
, GROUP_CONCAT(product_type.tName SEPARATOR FROM (sp_product
) LEFT OUTER JOINsp_product_type
ONsp_product_type
.tCategory
=sp_product
.type
WHEREperm_name
= 'bacon'
$this->db->select('product.name, product.price, product.perm_name, product.description, GROUP_CONCAT(product_type.tName SEPARATOR ',') as product_type.tName');
$this->db->from('product');
$this->db->where('perm_name', $this->uri->segment(2));
$this->db->join('product_type', 'product_type.tCategory = product.type', 'LEFT OUTER');
$query = $this->db->get();
任何想法,我做错了?
也许应该传递一个'false'参数到'select' - 因为错误的保护算法... – uzsolt 2012-02-17 10:09:46
我仍然得到一个错误:你的SQL语法错误;检查与您的MySQL服务器版本相对应的手册,以在'sp_product'附近使用正确的语法)LEFT OUTER JOIN'sp_product_type' ON'sp_product_type'.''tCategory''at line 1 – Claremont 2012-02-17 20:18:14