Join two tables where a column like column b

I need to join two tables where a column from table b matches the code from table 1. This is a payment checking system where the user puts in a reference number which can be surrounded by other words ie “E345 Payment”

SELECT *
  FROM invoice a, transactionProcess b
  WHERE INSTR(b.description, a.payment_id) > 0";

I have tried other join and non join queries although it is showing both the non matching and matching data, with matching data appearing twice

Fred      |a456 New money
Jake      |b455
Andrew    |payment 
frank     |income
FrED      |a456 New Money
Jake      |b455

Using INSTR I am able to retrieve the like id although I cannot gave it duplicating. Best option would be that I can have a column saying “match”. I’m not the most experienced with sql.

I am also aware of the query speed although this is my best option to extract payments.

You may also like...