1

So i have two table that looks like this:

Table 1

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

Table 2 (A string, that is somewhat a concat of Product and Version)

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

I want to be able to search Table1.Product and Table1.Version against Table2.Platform and return something like the following.

Table 3

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

I have tried using IS LIKE and INSTR but these don't seem to work.

Im not sure if its possible as the two tables have no relationship and the matches won't be exact, I'm looking for a sort of "Find in String" to isolate the product and the version out of the platform string.

My current query is:

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


Error: near "Table2": Syntax Error
1
  • "IS LIKE" is not correct sqlite syntax. The operator is "LIKE". Commented Mar 26, 2021 at 11:05

2 Answers 2

1

For this sample data you need a join of the tables and the operator LIKE in the ON clause:

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

See the demo.

Sign up to request clarification or add additional context in comments.

2 Comments

Could you clarify what the || ' ' || t1... stuff is. quite confused about that. Thank you though
|| is the concatenation operator of SQLite, so I concatenate Product and version to compare it against Platform.
0

Check if this works for you:

db2 "SELECT Table1.Product, Table1.Version, Table2.Description FROM Table2, Table1 where CONCAT(CONCAT(Table1.Product, ' '), Table1.Version) like (select SUBSTR(Platform, 1, 11) from Table2) "

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.