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


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -