开发struts时进行数据库模糊查询
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SearchForm searchForm = (SearchForm) form;
ActionMessages errors=new ActionMessages();
String name=searchForm.getName();
String phone=searchForm.getPhone();
String address=searchForm.getAddress();
if(!errors.isEmpty()){
saveErrors(request,errors);
return (new ActionForward(mapping.getInput()));
}
String sql = new String("SELECT * FROM info" + " WHERE ");
if (!name.equals(""))
sql=sql+?(按照name查询);
if (!phone.equals(""))
sql=sql+?(按照phone查询)
if (!address.equals(""))
sql=sql+?(按照address查询)
我用的是mysql数据库,请问那几个sql语句怎么写?