匹配字符串SQLite中的子字符串

  • 本文关键字:字符串 SQLite sqlite
  • 更新时间 :
  • 英文 :


所以我有两个表,看起来像这样:

表1

IP        | Product | Version
192.x.x.x | IBM BD2 | 9.7

表2(字符串,有点像产品和版本的连接(

ID  |  Platform                 | Description
50  |  IBM DB2 9.7 < FP11 40690 | This is XYZ

我希望能够根据Table2.Platform搜索Table1.Product和Table1.Version,并返回如下内容。

表3

Product  | Version | Description
IBM DB2  | 9.7     | This is XYZ

我试过使用IS LIKE和INSTR,但这些似乎不起作用。

我不确定这是否可能,因为这两张表没有关系,匹配也不准确,我正在寻找一种";在字符串中查找";以将产品和版本从平台字符串中隔离出来。

我当前的查询是:

SELECT Table1.Product Table1.Version Table2.Description FROM Table2, Table1 WHERE Table1.product IS LIKE Table2.platform

Error: near "Table2": Syntax Error

对于此示例数据,您需要表和ON子句中的运算符LIKE的联接:

SELECT t1.Product, t1.Version, t2.Description 
FROM Table1 t1 INNER JOIN Table2 t2 
ON t2.Platform LIKE t1.Product || ' ' || t1.Version || '%'

请参阅演示。

检查这是否适用于您:

db2";SELECT Table1.Product,Table1.Version,Table2.Description FROM Table2,Table1其中CONCAT(表1.Product,"(,Table1.Version(like(SELECT SUBSTR(Platform,1,11(FROM Table2(";

最新更新