mysql - one Field for 2 parameters in JAVA -
public arraylist searchcustomer(string cid) throws sqlexception { arraylist searchcustlist = new arraylist(); preparedstatement pstmt = connection.preparestatement("select * customer (custid = ? or firstname ?)"); pstmt.setstring(1, cid); pstmt.setstring(2, "%" + cid + "%");
please explain last command used 1 text field search customer name or id can body explain last line
your question unclear, if want understand :pstmt.setstring(2, "%" + cid + "%");
then set second parameter in sql query value of cid variable, , add % around
adding %
around, mean in sql 'any character', having %cid%
mean containing cid in it.
as actual query use cid either custid or firstname, mean user having specific id, or having in firstname id.
which strange, , looks more bug, logical query, maybe come old legacy having id in firstname, knows