3

I am aware that you can concatenate multiple columns within a single table with a query like this:

SELECT ( column1 || column2 || column3 || ... ) AS some_name FROM some_table

Is it possible to concatenate columns from multiple tables with a single sqlite query?

Very simple example - Two tables and the result:

        Table1              |           Table2          |         Result
  Col1          Col2        |            Col3           |
 -------------------------------------------------------------------------------
   A             B          |             C             |           ABC

If this is possible, what would the query be?

I can always manually concatenate multiple single table concatenation results, but having sqlite do all the work would be great:)

1 Answer 1

14

Try this

SELECT a.col1 || a.col2 ||  b.col3 AS 'SUM'
FROM table1 a, table2 b
WHERE a.id = b.id;

In where you have top mention the joining condition between the tables

Fiddle

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.