Connecting Tech Pros Worldwide Forums | Help | Site Map

Using LIKE to compare input to column

Newbie
 
Join Date: Sep 2009
Posts: 1
#1: Sep 19 '09
I'm trying to compare input data to what's stored on a DB2 table to see if there's a match, but DB2 stores the term I want to look for in the input field.

Table: TERM_TABLE
Column: TERM_COLUMN
Values in TERM_COLUMN:
%HOUSE%
%CONDO%
%APARTMENT%

I want to compare the input field to TERM_COLUMN so I can see if there's a match. INPUT-TERM = LARGE HOUSE ON HILL

SELECT *
FROM TERM_TABLE
WHERE :INPUT-TERM LIKE TERM_COLUMN

The error is:
An unexpected token "TERM_COLUMN" was found following "". Expected tokens may include ":".

So, what the error tells me is that I can do the opposite: try to compare the DB2 column with INPUT-TERM - I would have to put %HOUSE% into the host variable INPUT-TERM, but not what I'm trying to do. Any ideas?

Reply