Jsp中的SQL语句写法,高手进哦~~

2024年12月02日 11:28
有4个网友回答
网友(1):

String sql = "select * from record where choice like '"+%gjz%+"' and date >= '"+sdate+"' and date <='"+edate+"' order by date ";

ResultSet rs=stmt.executeQuery(sql);
'"+%gjz%+"'没有错

网友(2):

String sql = "select * from record where ('"+choice+"' like '%"+gjz+"%') and date >= '"+sdate+"' and date <='"+edate+"' order by date ";
百分号的位置的问题吧 另外choice是不固定的列名吗,要是固定的不用写成参数吧

网友(3):

"select * from record where ('"+choice+"' like '"+%gjz%+"') and date
改成
"select * from record where ("+choice+" like '%"+gjz+"%') and date

这样就行了

网友(4):

String sql = "select * from record where choice like '"+%gjz%+"' and date >= '"+sdate+"' and date <='"+edate+"' order by date ";
我猜你那个choice不是传的参吧?