主题:sqlexec()的问题,请大虾帮忙看一下
wuzm0624
[专家分:0] 发布于 2010-01-12 13:07:00
sqlexec(nhandle,"select db_product.h_id,db_product.h_isbn,db_product.h_name,db_product.h_output_price,sum(db_ls_item.h_amount) from db_product join db_ls_item on db_ls_item.h_id=db_product.h_id join db_ls on db_ls.ls_id=db_ls_item.ls_id where db_ls.m_id='MM0000000170679' group by db_product.h_id,db_product.h_isbn,db_product.h_name,db_product.h_output_price ","gh")
以上语句在SQL里执行没有问题,但在VP就出错,但把group by db_product.h_id,db_product.h_isbn,db_product.h_name,db_product.h_output_price 这段删除就不会存在问题,是不是语句过长????
回复列表 (共3个回复)
沙发
agt澳 [专家分:840] 发布于 2010-01-12 17:42:00
[color=0000FF][size=3]
对的,应该语句过长,vfp好象一行不能超过256字,你可以用变量
C_Sql="selectdb_product.h_id,db_product.h_isbn,db_product.h_name,db_product.h_output_price,sum(db_ls_item.h_amount) "
C_Sql=C_Sql+"from db_product join db_ls_item on db_ls_item.h_id=db_product.h_id join db_ls on db_ls.ls_id=db_ls_item.ls_id where db_ls.m_id='MM0000000170679' "
C_Sql=C_Sql+"group by db_product.h_id,db_product.h_isbn,db_product.h_name,db_product.h_output_price"
sqlexec(nhandle,C_Sql,"gh") [/size][/color]
板凳
sywzs [专家分:5650] 发布于 2010-01-13 06:17:00
整个语句中好像用到了三个表(db_product、db_ls_item和db_ls),给这三个表起个别名a、b和c,可以给整个语句减减肥。
cSQL="select a.h_id,a.h_isbn,a.h_name,a.h_output_price,sum(b.h_amount) from db_product a join db_ls_item b on b.h_id=a.h_id join db_ls c on c.ls_id=b.ls_id where c.m_id='MM0000000170679' group by a.h_id,a.h_isbn,a.h_name,a.h_output_price"
sqlexec(nhandle,cSQL,"gh")
3 楼
qjbzjp [专家分:8830] 发布于 2010-01-13 09:59:00
用分号断成几行试试。
我来回复