Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CONCAT Function in SQLite : Error - SQL Error [1]: [SQLITE_ERROR] SQL error or missing database (no such function: CONCAT)

Tags:

sql

sqlite

I am trying to CONCAT the DATA FROM my EMPLOYEE TABLE

TABLE EMPLOYEE 
============================================== 
empno ename   Job           salary    deptno
----------------------------------------------
101   Roy     Programmer    5000      20
102   Todd    Analyst       6000      10
105   Leslie  Analyst       5500      20
107   Cindy   Developer     7200      30

with these queries

SELECT CONCAT(ename || 'is getting paid' || salary || 'for' || job)
FROM EMPLOYEES
WHERE empno = 101;
-- and 
SELECT CONCAT(ename, 'is getting paid', salary, 'for', job)
FROM EMPLOYEES
WHERE empno = 101;

But both result in the error:

SQL Error [1]: [SQLITE_ERROR] SQL error or missing database (no such function: CONCAT)'

Expected Output:

"Roy is getting paid 5000 for Programmer"

Please assist!

like image 569
R S Rathore Avatar asked Jun 07 '26 13:06

R S Rathore


1 Answers

Use the concatenation operator || to concatenate strings. (As you actually already did.)

SELECT ename || ' is getting paid ' || salary || ' for ' || job
FROM employees
WHERE empno = 101;

The search result for concat in the sqlite documenation did not return any meaningfull hits.

  • There is an opcode with the name concat.
  • In operators this is written:

The || operator is "concatenate" - it joins together the two strings of its operands

So it seems that there is no function concat(). But as mentionend above the operator || can be used.

like image 198
sticky bit Avatar answered Jun 10 '26 04:06

sticky bit



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!