sazr
sazr

Reputation: 25928

SQLite3 Concatenation Query Fails for some reason

Why does the following SQLite3 query fail with the error:

SQL Exception: near "||": syntax error

My Query:

UPDATE test 
SET money_links||='http://www.test.com', u_links||='http://www.test.com' 
WHERE u_tag='test2';

The structure of the table test is:

CREATE TABLE IF NOT EXISTS  test(u_tag TEXT PRIMARY KEY, money_links TEXT, u_links TEXT);

Upvotes: 0

Views: 271

Answers (2)

Hogan
Hogan

Reputation: 70529

UPDATE test 
SET money_links = money_links + 'http://www.test.com', u_links = u_links+ 'http://www.test.com' 
WHERE u_tag='test2';

UPDATE test 
SET money_links = ISNULL(money_links,'') + 'http://www.test.com', u_links = ISNULL(u_links,'') + 'http://www.test.com' 
WHERE u_tag='test2';

Upvotes: 2

eumiro
eumiro

Reputation: 213005

Do you want to do something like this?

UPDATE test 
SET money_links = money_links || 'http://www.test.com',
    u_links = u_links || 'http://www.test.com' 
WHERE u_tag='test2';

I am afraid SQL does not allow such "incremental concatenation" like some real programming languages.

Upvotes: 1

Related Questions