I have the following code, which i want to compare two strings (varchars).
If item.item_name contains the string equipment_type anywhere, i want it to return the record.
But i recieved a error, stating INVALID NUMBER on the upper('%' + equipment_type + '%') command.
select * from equipment_type
join item on upper(item.item_name) like upper('%' + equipment_type + '%')
I realize the issue is adding the wildcard strings to the variable equipment_type. Does anyone know how to get this wildcard comparison to work?
Note: I originally answered this in the comments. Since then, it was suggested that I post the solution here as a "real" answer. Here goes...
Oracle uses + for numeric and date math only. For string concatenation, use double bars (||
):
select * from equipment_type
join item on upper(item.item_name) like upper('%' || equipment_type || '%')
The only changes are here ^^ ... and here ^^