2016-12-07 39 views
-1

我试图基于某种逻辑从数据库get数据值,这里是查询的SQLite结合的两列

String sql = "SELECT pr.number, pr.u_id from pro_cap pr " + 
"LEFT OUTER JOIN pending p " + 
"WHERE p.mobile_id = pr.u_id+pr.infant_no "; 

凡的valuemobile_id未决4711

并且valueu_id471并且值号码1pro_cap

我想从数据库中获取数据,其中4711 = 4711,但无法获得...

+2

'471 + 1 = 472'。显示表结构。 –

+4

'''是用于字符串concat ...但是有像u_id = 47和number = 11的陷阱...将与u_id = 471和number = 1相同......为什么不使用2列外键 – Selvin

回答

3

对于连接两个或多个列使用||操作。

更改如下查询:

String sql = "SELECT pr.number, pr.u_id from pro_cap pr " + 
"LEFT OUTER JOIN pending p " + 
"WHERE p.mobile_id = pr.u_id || pr.infant_no ";