0

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.

master-lame-master
  • 3,101
  • 2
  • 30
  • 47
  • 1
    See: http://stackoverflow.com/questions/278189/what-is-the-string-concatenation-operator-in-oracle – Barmar May 02 '14 at 16:57

2 Answers2

3

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

smth LIKE (SELECT .. FROM ..) || '%'
Barmar
  • 741,623
  • 53
  • 500
  • 612
0

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).

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786