Trying to get the following query to run but keep getting an error.
Select field1, field2, if(length(field3) >10,“Red”, “Black”) as misc from table1
I want the 3rd field of the resulting query to be based on the length of field3
Thanks
Trying to get the following query to run but keep getting an error.
Select field1, field2, if(length(field3) >10,“Red”, “Black”) as misc from table1
I want the 3rd field of the resulting query to be based on the length of field3
Thanks
What DB backend? What error?
What database engine are you using? Is “length” the correct function? SQL server I think uses Len for example.
REALSQLdb
I also tried “len”
I heard it was an ancient SQLite, so maybe this works there
SELECT field1, field2, CASE WHEN LENGTH(field3) > 10 THEN 'Red' ELSE 'Black' END AS misc FROM table1
length(field3) as misc works
it fails when I include the “if”
Rick, trying it now…
Alternatively try “iif” function. Short for inline if. That’s supposed to work with SQLite but I’m not sure which version it started with.
All
Thanks for your interest and quick response.
Rick A - Thanks!! it worked.
I’ve been using my REALSQLdb for many many years. Maybe it’s time to investigate an upgrade.
Jim
SQLite is the engine behind RealSQLdb. It would likely be a direct replacement.
Ian
Thanks
Will start looking into updating today