Hi all,
I am trying to assign the terminals to the company by searching from the terminal name using search string in the company table.
The input from 2 tables: company table and terminal table
I am using query builder based on the company input table to assign the company.
SELECT * FROM TERM_TABLE
WHERE NAME LIKE ANY ('%PAYPAL%','%PAYPAL%ATM%')
The problem is after running the search, the terminal can have multiple companies as per current output below.
In this case, I would like the solution to find the first search string first (using CHARINDEX or something) then assign to the company ID
eg. PAYPALxxxJETSTAR assign to PAYPAL not JETSTAR
Appreciate on you guys input on this.
Thanks Guys,
I am trying to assign the terminals to the company by searching from the terminal name using search string in the company table.
The input from 2 tables: company table and terminal table
Code:
Company_Table
Company_ID Name Search_String
1 PAYPAL '%PAYPAL%','%PAYPAL%ATM%'
2 JETSTAR '%JETSTAR%','%JETSTAR%AIR'
Terminal_Table
Terminal_ID Name Company_ID
1 PAYPALxxxJETSTAR NULL
2 BLAxBLA NULL
I am using query builder based on the company input table to assign the company.
SELECT * FROM TERM_TABLE
WHERE NAME LIKE ANY ('%PAYPAL%','%PAYPAL%ATM%')
The problem is after running the search, the terminal can have multiple companies as per current output below.
Code:
Terminal_ID Name Company_ID
1 PAYPALxxxJETSTAR 1
1 PAYPALxxxJETSTAR 2
2 BLAxBLA NULL
In this case, I would like the solution to find the first search string first (using CHARINDEX or something) then assign to the company ID
eg. PAYPALxxxJETSTAR assign to PAYPAL not JETSTAR
Appreciate on you guys input on this.
Thanks Guys,