Pergunta

I have an Open Office database. I'd like to use the LIKE operator with "%" marks between two columns in the same table:

SELECT * FROM "table1" WHERE UPPER ( "table1"."a" ) LIKE UPPER ('%' + "table1"."b" + '%' )

But it doesn't work, although

SELECT * FROM "table1" WHERE UPPER ( "table1"."a" ) LIKE UPPER ("table1"."b")

works. What's wrong in my syntax?

Foi útil?

Solução

Missing a + on the front after the % and before table.

SELECT [insert your fields here] FROM "table1" WHERE UPPER ( "table1"."a" ) LIKE UPPER ('%' + "table1"."b" + '%' )

Updated

SELECT [insert your fields here] FROM "table1" WHERE UPPER ( "table1"."a" ) LIKE '%' + UPPER("table1"."b") + '%' 

I'm assuming A and B are both of the same data type.

I'm assuming + is an string concat in openoffice. other possible values are || or &

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top