문제

In SQL Server T-SQL I used to use the scenario like this

SELECT .. FROM .. WHERE sometable.eng LIKE (SELECT tmpcolumn FROM tmptable WHERE tmpID = @counter) + '%';

How to pass LIKE (subquery) + '%' in Oracle correcly? Does it actually work for Oracle 11g+ or not?

.. smth LIKE (SELECT .. FROM ..) + '%';

The underscore _ for fixed length doesn't fit my needs, so % only.

도움이 되었습니까?

해결책

Oracle uses || for string concatenation, not +. So it should be:

smth LIKE (SELECT .. FROM ..) || '%'

다른 팁

This seems like such an odd formulation. Just as a note, I would write the query as:

SELECT ..
FROM ..
WHERE EXISTS (SELECT 1
              FROM tmptable
              WHERE tmpID = @Counter AND
                    sometable.eng LIKE tmpcolumn || '%'
             );

Putting a subquery between the keyword LIKE and the wildcard makes the query harder to read (at least for me).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top