-2

I have a mysql table which has data in column 1, and data is S01E01. When I run:

select * from tableName where "column 1" like "S%"

it works properly, but when I run:

select * from tablename where "column 1" like "S0%"

it doesn't work (returns empty set).

I think it occurs when I insert a number in double quotes.

what is problem and how to solve it?

redhotspike
  • 1,056
  • 5
  • 17
  • 39
  • 1
    Then there's no record with 'S0%' – Eric Aug 07 '18 at 18:25
  • 1
    Learn how to ask question here. https://stackoverflow.com/help/how-to-ask – Eric Aug 07 '18 at 18:26
  • Possible duplicate of [When to use single quotes, double quotes, and back ticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql) – Progman Aug 07 '18 at 20:56

1 Answers1

1

Instead of ", use ` on the field_name.

select * from tablename where `column 1` like "S0%"
Tanvir Ahmed
  • 483
  • 3
  • 10
  • Also if possible please change the field name into column_1 (remove the space). For example if you fetch the result data as array of objects, then the column name will be a key in the object. – Tanvir Ahmed Aug 07 '18 at 21:01