I had the following query (with bin_number
being a string) which was working on MySQL 5.5:
Postgres - was working on MySQL and doesn't work on PostgreSQL
SELECT "menu_items".*
FROM "menu_items"
WHERE ((header like '%red%'
or detail like '%red%'
or bin_number like '%red%')
and location_id='37'
and is_deleted=false and bin_number<>'')
ORDER BY bin_number asc;
> 0 results # should be 17
Postgres - works so issues with and bin_number<>''
SELECT "menu_items".*
FROM "menu_items"
WHERE ((header like '%red%'
or detail like '%red%'
or bin_number like '%red%')
and location_id='37'
and is_deleted=false)
ORDER BY bin_number asc;
> 17 results
I tried changing bin_number<>''
to bin_number!=''
but that didn't make a difference.
Why is this not working?
The bin_number in menu_items is declared as:
bin_number | character varying(255) | | extended | |
location_id
? Why is an integer in quotes?37
is a number,'37'
is a string.