yszc / qeephp

Automatically exported from code.google.com/p/qeephp
0 stars 0 forks source link

QDB_Select 使用 DISTINCT 生成的 SQL 不正确 #125

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
QDB_Select 使用 DISTINCT 生成的 SQL 不正确

Original issue reported on code.google.com by dualf...@gmail.com on 3 May 2009 at 2:26

GoogleCodeExporter commented 9 years ago
 SELECT DISTINCT COUNT(*)   FROM `pramdevpeng`.`products`  INNER JOIN
`pramdevpeng`.`category_has_products`   ON
(pramdevpeng.category_has_products.productid = products.productid)  INNER JOIN
`pramdevpeng`.`category`   ON (pramdevpeng.category.cate_id =
pramdevpeng.category_has_products.cate_id)   WHERE
((`pramdevpeng`.`category`.`left_value`>=1 and
`pramdevpeng`.`category`.`right_value`<=474 ) AND (productonline=1 and 
manufacturer
like '%Phil & Teds%'))

Original comment by dualf...@gmail.com on 3 May 2009 at 2:28

GoogleCodeExporter commented 9 years ago
正确的查询应该是:

{{{
SELECT COUNT(*) FROM (SELECT DISTINCT `pramdevpeng`.`products`.* FROM
`pramdevpeng`.`products`  INNER JOIN
`pramdevpeng`.`category_has_products`   ON
(pramdevpeng.category_has_products.productid = products.productid)  INNER JOIN
`pramdevpeng`.`category`   ON (pramdevpeng.category.cate_id =
pramdevpeng.category_has_products.cate_id)   WHERE
((`pramdevpeng`.`category`.`left_value`>=1 and
`pramdevpeng`.`category`.`right_value`<=474 ) AND (productonline=1 and 
manufacturer
like '%Phil & Teds%'))
) TMP_ALIAS

}}}

Original comment by dualf...@gmail.com on 3 May 2009 at 2:34