0

I have a simple query that isn't working.

select * 
from table 
where '"Name (xyz)"' LIKE '%AB CD EF G%';

I am trying to return the row such that the column Name (xyz) = AB CD EF G . I have checked and my database does contain such a data entry but still the query yields 0 results yet no error messages. The spaces in the column name and desired search parameter are there by design.

daniel stafford
  • 241
  • 1
  • 8
  • I am not understanding what `'"Name (xyz)"'` is supposed to represent? Right now you are asking if the string `'"Name (xyz)"'` is `LIKE` the string `'%AB CD EF G%'` which I am pretty sure is not your intent. – Adrian Klaver Nov 05 '21 at 21:40
  • '"Name (xyz)"' Is the column name. So i am trying to return rows such that this column has the value ```LIKE '%AB CD EF G%'``` – daniel stafford Nov 05 '21 at 21:42
  • 1
    Then no single quotes as that turns the identifier(column name) `"Name (xyz)"` into a string. – Adrian Klaver Nov 05 '21 at 21:49
  • BTW, *"such that the column Name (xyz) = AB CD EF G"* translates to `"Name (xyz)" = 'AB CD EF G'`, no `LIKE`. – Erwin Brandstetter Nov 06 '21 at 02:43

1 Answers1

1

try this :

select * 
from table 
where "Name (xyz)" LIKE '%AB CD EF G%';
Edouard
  • 6,577
  • 1
  • 9
  • 20