query="select friend_uname from myfriends";//SELECT ALL THE FRIENDS OF THE USER
System.out.println(query);
rs=stmt.executeQuery(query);
query="select * from service_provider where source=\""+source+"\" and dest=\""+dest+"\" and resources>0 and provider_name IN(?);";
System.out.println(query);
prest=conn.prepareStatement(query);
while(rs.next())
{
x=rs.getString("friend_uname");//SELECT THE FRIEND NAMES OF THE USER ONE BY ONE...
System.out.println("THE friend_uname IS"+ x);
prest.setString(1,x);//SET THE iTH POSITION OF THE STRING AS THE FRIEND NAME
}
答案 0 :(得分:0)
尝试此查询
query="select * from service_provider where source=\""+source+"\" and dest=\""+dest+"\" and resources>0 and provider_name IN(select friend_uname from myfriends)";
或尝试使用加入查询
query="select sp.* from service_provider sp, myfriends myfrnd where sp.source=\""+source+"\" and sp.dest=\""+dest+"\" and sp.resources>0 and sp.provider_name=myfrnd.friend_uname";