Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacement for Left command in SQLite SQL

Tags:

sql

sqlite

I have the following query that works fine in MS Access, MySQL and SQL Server but when I try to use it in SQLite I get an error:

near "(": syntax error:

I can't find the Left command in any documentation of SQLite so I guess it isn't there but how could I get it to work then.

SELECT 
    Left(fldcall, 3) AS Group1, 
    Mid(fldcall, 4, 1) AS Group2, 
    tblcalls.*, 
    tblzip.fldcity
FROM 
    tblcalls 
LEFT JOIN 
    tblzip ON tblcalls.fldzipcode = tblzip.fldzipcode;
like image 961
OZ8HP Avatar asked Jul 20 '26 22:07

OZ8HP


1 Answers

You can use the substr() function instead:

SELECT substr(fldcall, 1, 3) AS Group1,
       substr(fldcall, 4, 1) AS Group2,
       tblcalls.*,
       tblzip.fldcity
FROM tblcalls
LEFT JOIN tblzip USING (fldzipcode);
like image 172
CL. Avatar answered Jul 23 '26 21:07

CL.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!