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

2024-12-02 11:28:05
推荐回答(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不是传的参吧?