0

私はこのクエリを持っています:

$this->db->select('COUNT(tran_ID) AS count, CASE WHEN MONTH(days)>=4 THEN concat(YEAR(days), "-", YEAR(days)+1) ELSE concat(YEAR(days)-1, "-", YEAR(days)) END AS format_date,product_class AS saleCol');

で構文エラーが発生します

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 'WHEN MONTH(days)>=4 THEN concat(YEAR(days), `"-"`, YEAR(days)+1) ELSE concat(YEA' at line 1

SELECT COUNT(tran_ID) AS count, `CASE` WHEN MONTH(days)>=4 THEN concat(YEAR(days), `"-"`, YEAR(days)+1) ELSE concat(YEAR(days)-1, `"-"`, YEAR(days)) END AS format_date, `product_class` AS saleCol FROM (`transactions`) WHERE `trans_type` = 'E' AND `product_class` != '0' GROUP BY `format_date`, `product_class`
4

1 に答える 1

1

FALSEselectステートメントの2番目のパラメーターとして追加されたこのクエリを試してください

$this->db->select(
                  'COUNT(tran_ID) AS count, 
                   CASE WHEN MONTH(days)>=4 THEN concat(YEAR(days), "-", YEAR(days)+1)
                     ELSE concat(YEAR(days)-1, "-", YEAR(days)) 
                   END AS format_date,
                   product_class AS saleCol',FALSE);
于 2013-01-10T09:14:53.073 に答える