-2

How to retrieve a column containing special characters including alphabets in SQL Query. i have a column like this 'abc%def'. i want to retrieve '%' based columns from that table.

Please help me in this regard.

Rahul
  • 76,197
  • 13
  • 71
  • 125

2 Answers2

0

Is abc%def the column name? or column value? Not sure what you are asking but if you mean your column name contains special character then you can escape them which would be different based on specific RDBMS you are using

SQL Server use []

select [abc%def] from tab

MySQL use backquote

select `abc%def` from tab

EDIT:

Try like below to fetch column value containing % character (Checked, it works in Ingres as well)

select * from tab where col like '%%%'
Rahul
  • 76,197
  • 13
  • 71
  • 125
0

Others suggest that like '%%%' works in Ingres. So this is something special in Ingres. It does not work in other dbms.

In standard SQL you would have to declare an escape character. I think this should work in Ingres, too.

select * from mytable where str like '%!%%' escape '!';
Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73