我在postgresql中查询并得到结果,但是当实现到文本编辑器时,我得到这样的错误:
语法错误,意外令牌(靠近' SelOrdersdetil d INNER JOIN SelOrders使用(o_kode))INNER JOIN SelMmenu m USING(sel_mmenu_id)GROUP BY d.sel_mmenu_id,m.nama,m.olahan LIMIT 30& #39;,解析时:SELECT d.sel_mmenu_id,m.nama,m.olahan,sum(d.od_qty)AS qty,sum(d.od_jmlhrg)AS名义FROM(SelOrdersdetil d INNER JOIN SelOrders p USING(o_kode)) INNER JOIN SelMmenu m USING(sel_mmenu_id)GROUP BY d.sel_mmenu_id,m.nama,m.olahan LIMIT 30(269)
如何修复,我使用phalcon和我的代码:
SELECT d.sel_mmenu_id, m.nama, m.olahan, sum(d.od_qty) AS qty,
sum(d.od_jmlhrg) AS nominal FROM (sel_ordersdetil d
INNER JOIN sel_orders p USING (o_kode))`
INNER JOIN sel_mmenu m USING(sel_mmenu_id)
GROUP BY d.sel_mmenu_id, m.nama, m.olahan LIMIT 30
thaks
答案 0 :(得分:0)
您不需要FROM
子句中的括号:
SELECT d.sel_mmenu_id, m.nama, m.olahan, sum(d.od_qty) AS qty,
sum(d.od_jmlhrg) AS nominal
FROM sel_ordersdetil d INNER JOIN
sel_orders p
USING (o_kode) INNER JOIN
sel_mmenu m
USING (sel_mmenu_id)
GROUP BY d.sel_mmenu_id, m.nama, m.olahan
LIMIT 30;
说实话,我希望查询能与括号一起使用。
此外,使用不LIMIT
的{{1}}也很危险。您应该包含ORDER BY
。