select * from t_resident where username in("xxx","xx");
username 是个varchar2,"xxx"(varchar2),"xx"(varchar2)是根据select语句查询出的所以不能使用or
怎么实现:
select * from t_resident where id in("xxx","xx");一样的功能但是不是id而是username.
...全文
1106打赏收藏
大神求助
select * from t_resident where username in("xxx","xx"); username 是个varchar2,"xxx"(varchar2),"xx"(varchar2)是根据select语句查询出的所以不能使用or 怎么实现: select * from t_resident where id in("xxx","xx");一样的功能但是不是id而是username.
再看了一遍楼主的意思。估计我懂了。但是不知道楼主的这个username只有一个还是有很多个?
如果只有一个:select * from t_resident where username='username1';
如果不只一个:select * from t_resident where username=select username from tablename where contant='contant1'or like'%' ;
看楼主怎么发挥想象力了。能看懂我的意思就给分吧。
我估计看懂了楼主的意思:就是in后面的参数也是通过查询获得的结果,是不定的。但这个in里面的参数都是字符串的。
楼主的:select * from t_resident where id in("xxx","xx");
如果直接知道username是什么就直接写,如果不知道就通过查询获得。
我的;select * from t_resident where username in("username1","username2");
或者是直白点:select * from t_resident where username in("张山","李四");
or:select * from t_resident where username in(select username from tablename where x=y);
其中x=某一个表的某一个字段y=某一个表的某一个字段的值。