Join column from a table with concat columns from another one

Plouf

I try to match names from a table with a concatenation of columns in another table with Postgres.

What I have:

Table A:

id,name
1,John Smith
2,Laura Doe Van Renburg
3,Laura Thorpe
4,Carl Leonard Dong

Table B:

id,firstname,lastname
1,Aloys,Smith
2,Laura,Doe Van Renburg
3,Pedro,De Mung
4,Carl Leonard, Dong

The result I expect

Laura Doe Van Renburg
Carl Leonard Dong

What I tried

I think concatening the columns firstname and lastname from table B could help but I can't figure out what the correct syntax is.

select A.name from A 
  join (select concat(firstname,' ',lastname) from B) as firstandlast 
  on a.name = firstandlast;

But it's not the correct way. Any clue would be welcome!

a_horse_with_no_name

You were close:

select a.name 
from table_a a
  join table_b b on concat(b.firstname, ' ', b.lastname) = a.name

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Join multiple values from one column, selected from another table

From Dev

insert statement one column from another table rest of the columns is values

From Dev

Procedure to insert data from one column into two columns in another table

From Dev

How to get all columns from one table and only one column from another table with ID ? - MySql

From Dev

Join two columns in one table to a column in another reference table

From Dev

Join two columns in one table to a column in another reference table

From Dev

How to: JOIN one column from one table to 2 columns in the other table?

From Dev

Join a columns count from another table

From Dev

Query to join multiple columns from one table

From Dev

Select all columns from one table and one from another where column equals variable

From Dev

SQL Select two columns from one table translated by a column from another table

From Dev

r - data.table join and then add all columns from one table to another

From Dev

Move table columns from one row into another

From Dev

SQL Join (all from one table and one from another)

From Dev

SQL query to copy from some columns of a table to one column in another table

From Dev

How to get value from one table column when two columns of the same name exist in an sql join

From Dev

Copying a column from one table to another

From Dev

Getting "subquery returns more than one row" error whenever trying to join a column from another table as alias?

From Dev

join count from one table to select from another - mysql

From Dev

MYSQL join one colum from one table to two count() in another

From Dev

SQL Query to compare two columns with one column from another table (and get two values)

From Dev

Getting data from one table to another table using join

From Dev

I need to merge data from 2 columns to another column. And then merge all rows of that added column into one cell in another table

From Dev

link a value from one table to another and slice one table based on columns from another table in sql

From Dev

Display 2 columns from one table having max count in column 3 and display computed sum of values from another table

From Dev

Compare one column from one file with all columns in another file

From Dev

MariaDB: Select the fields from one column in one table that are not in a subset of another column from another table

From Dev

Join multiple columns to another table to return description from number

From Dev

Display records from one table which is not in another table by multiple columns

Related Related

  1. 1

    Join multiple values from one column, selected from another table

  2. 2

    insert statement one column from another table rest of the columns is values

  3. 3

    Procedure to insert data from one column into two columns in another table

  4. 4

    How to get all columns from one table and only one column from another table with ID ? - MySql

  5. 5

    Join two columns in one table to a column in another reference table

  6. 6

    Join two columns in one table to a column in another reference table

  7. 7

    How to: JOIN one column from one table to 2 columns in the other table?

  8. 8

    Join a columns count from another table

  9. 9

    Query to join multiple columns from one table

  10. 10

    Select all columns from one table and one from another where column equals variable

  11. 11

    SQL Select two columns from one table translated by a column from another table

  12. 12

    r - data.table join and then add all columns from one table to another

  13. 13

    Move table columns from one row into another

  14. 14

    SQL Join (all from one table and one from another)

  15. 15

    SQL query to copy from some columns of a table to one column in another table

  16. 16

    How to get value from one table column when two columns of the same name exist in an sql join

  17. 17

    Copying a column from one table to another

  18. 18

    Getting "subquery returns more than one row" error whenever trying to join a column from another table as alias?

  19. 19

    join count from one table to select from another - mysql

  20. 20

    MYSQL join one colum from one table to two count() in another

  21. 21

    SQL Query to compare two columns with one column from another table (and get two values)

  22. 22

    Getting data from one table to another table using join

  23. 23

    I need to merge data from 2 columns to another column. And then merge all rows of that added column into one cell in another table

  24. 24

    link a value from one table to another and slice one table based on columns from another table in sql

  25. 25

    Display 2 columns from one table having max count in column 3 and display computed sum of values from another table

  26. 26

    Compare one column from one file with all columns in another file

  27. 27

    MariaDB: Select the fields from one column in one table that are not in a subset of another column from another table

  28. 28

    Join multiple columns to another table to return description from number

  29. 29

    Display records from one table which is not in another table by multiple columns

HotTag

Archive