I can use @ in mysql. But I can't use @ in java(jdbc). Could you give some advice?
mysql (working very well)
select ssn from (select * from EMPLOYEE)EMPLOYEE_sorted,(select
@pv='888665555') initialisation where find_in_set(superssn,@pv) and length(@pv
:= concat(@pv,',',ssn));
java (jdbc) doesn't work
String query = "select ssn from (select * from EMPLOYEE)EMPLOYEE_sorted,
(select @pv=888665555) initialisation where find_in_set(superssn,@pv) and length(@pv := concat(@pv,',',ssn))"
To set this you may create a PreparedStatement and assign '?' wherever you want to place the @xxxxxx.
To set the values inside the '?' you have to use the command
setString()/setInt()/set<variable>();
This is more clear when I show you an example.
PreparedStatement p = con.prepareStatement("select * from people where
(first_name = ? or last_name = ?) and address = ?");
p.setString(1, name);
p.setString(2, name);
p.setString(3, address);
Here is the link to the sample.
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.