i want to join two tables using common column, but in one table the column is having comma seperated values how can i join those tables?
i try with like operator but not got exactly. please tell me the solution
the master table name is 'languages' and second table is 'pepople'
Tbale 1 : languages (id int,desc varchar)
--------------------------------
lang_id | lang_desc
---------------------
1 | English
2 | Telugu
3 | Hindi
Table 2 : peopele (id int,name varchar,lang_id varchar)
------------------------------------------------------
id | name | lang_id
----------------------------
1 | Apple | 1,2
2 | Grape | 3,1
i try with
and second trial is:
i actually need result as below
id | name | lang_id | lang_desc
------------------------------------------
1 | Apple | 1 | English
1 | Apple | 2 | Telugu
2 | Grape | 3 | Hindi
2 | Grape | 1 | English
Please tell the way to do this
i try with like operator but not got exactly. please tell me the solution
the master table name is 'languages' and second table is 'pepople'
Tbale 1 : languages (id int,desc varchar)
--------------------------------
lang_id | lang_desc
---------------------
1 | English
2 | Telugu
3 | Hindi
Table 2 : peopele (id int,name varchar,lang_id varchar)
------------------------------------------------------
id | name | lang_id
----------------------------
1 | Apple | 1,2
2 | Grape | 3,1
i try with
Code:
select p.id,p.name,l.lang_id,l.lang_desc
from langages l join people p on p.lang_id=l.lang_id
but this query returned zero records
Code:
select p.id,p.name,l.lang_id,l.lang_desc
from langages l join people p
on l.lag_id::varchar like '%,'+p.lang_id::varchar+',%'
this query given ERROR: operator does not exist: unknown + character varying
id | name | lang_id | lang_desc
------------------------------------------
1 | Apple | 1 | English
1 | Apple | 2 | Telugu
2 | Grape | 3 | Hindi
2 | Grape | 1 | English
Please tell the way to do this