I currently confused at how to set wildcards for long values when using select in databases. Currently I have:
preparedstatement= conn.prepareStatement("SELECT * FROM database WHERE LONGVALUES LIKE ? ");
preparedstatement.setLong(1, aLongValue);
I am currently confused on how to use a wild card to get the results that I want. What I want to select is all values from that database whose LONGVALUES
column contains the number aLongValue
. So if 52
is in the database entering 5
or 2
would select it.
You can't do LIKE
on a numerical value. It must be a string so you should either make LONGVALUES
a VARCHAR field or use a scalar function to convert the value to a string in line with your query ie
SELECT * FROM database WHERE TO_CHAR(LONGVALUES) LIKE ?;
要使用LIKE,您的aLongValue应该是varchar,那么您可以运行...,其中longvalue类似于'%5%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.