Dynamic 'LIKE' Statement in SQL (Oracle)
You can use the CONCAT()
function:
SELECT * FROM MATERIALS WHERE longname LIKE CONCAT(shortname, '%')
or even better, the standard || (double pipe)
operator:
SELECT * FROM MATERIALS WHERE longname LIKE (shortname || '%')
Oracle's CONCAT()
function does not take more than 2 arguments so one would use the cumbersome CONCAT(CONCAT(a, b), c)
while with the operator it's the simple: a || b || c