简体   繁体   中英

generic upper case search on postgres and mysql not working

I am trying to do an easy search on a table that can be on any kind of database. The following query is working an the most databases, but I cannot find a solution which works on mysql. The tables in my database are generated by the active objects framework, so I cannot change the names or config of those instances.

Here is the query that works fine on all databases but MySQL:

select * from "AO_69D057_FILTER" where "SHARED" = true AND "CONTAINS_PROJECT" = true AND UPPER("FILTER_NAME") like UPPER('%pr%').

MySql is not able to use the table name in double quotes for some reason. If I use the unquoted table name it works on MySQL but not on Postgres. Postgres is converting the table name to lowercase because it is unquoted. AO is generating the table names in upper case.

I also tried to use an alias, but that can not work because of the evaluation hierarchy of the statement.

Any suggestions how to get rid of the table name problem?

By default double quotes are used to columns. You can change it:

SET SQL_MODE=ANSI_QUOTES;

Here is the documentation about it: http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM