问题:出现的原因是 groupby后接的变量是一个字符串String类型,$selectRow变量中有.号,groupby会认为这是拼接两个字符串的符号,导致拼接成sql查询时,以.为分隔符 出现类似这样的情况
select delivery.customers_name,delivery.project_name,SUM(product_cube) as product_cube from delivery inner join mixing_plant on mixing_plant.id = delivery.mixing_plant_id inner join ipc on ipc.ipc_id = delivery.ipc_id where (ipc_type = 0) and 1=1 group by delivery.customers_name,delivery.project_name
解决办法:直接拿数组中的值
print_r($fields);
Array ( [0] => mixing_plant.short_name [1] => delivery.customers_name [2] => delivery.project_name [3] => delivery.print_concrete [4] => delivery.slump_level [5] => delivery.construction_place [6] => delivery.pouring_method [7] => delivery.ipc_id )

SQL查询错误处理与数组使用
博客内容涉及SQL查询中的一个问题,即在使用groupby时遇到字符串中的点号导致的解析错误。解决方案是通过使用数组中的值而不是带有点号的字符串进行groupby操作。文章提到了SQL查询的完整结构,并展示了如何正确地使用数组元素来避免此类问题。
653

被折叠的 条评论
为什么被折叠?



