62,614
社区成员
发帖
与我相关
我的任务
分享
。。。。。where t.name like '%&%'
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Main {
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/bc?" +
"user=root&password=Bao880831");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from t_test where name like '%&&%'");
while (rs.next()) {
System.out.println(rs.getString("name")); // 输出 &&
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
select * from user1 as u WHERE u.`name` LIKE '%\\&%'