MySQL中的SQL语句可以这样写:
SELECT *
FROM newtable
WHERE newimage1 = 'xxx' OR newimage2 = 'xxx' OR newimage3 = 'xxx';
Java代码:
rs=st.executeQuery("SELECT * FROM newtable WHERE newimage1 = '" + newsid
+ "' OR newimage2 = '" + newsid
+ "' OR newimage3 = '" + newsid + "';");
if(rs.next()){
//sid在newimage1、newimage2、newimage3中的某个字段中存在
}
select * from newstable
where newsimage1="+newsid+"
or newsimage2="+newsid+"
or newsimage3="+newsid+" ;用或者是不是也可以满足你的这种需求