Reputation: 11
Table "sub":
----------------------
sub_ser ----->column name
----------------------
a1
a2
a3
a4
----------------------
Table "zvm"
--------------------------
vms_ser ->column name
------------------------
a1,a2,a3
a1,a2
a1
----------------------
let's say both tables have only one column.. Query needed: to fetch the column "sub_ser" from the table "sub" which contains independent entries for all the entries which are arranged in combinations as shown in table "zvm".
ex: for the single entry "a1,a2,a3" in the table "zvm" we need to check whether each of the a1 and a2 and a3 are INDIVIDUALLY/ INDEPENDENTLY present in the table "sub" Hope u got the question...
Upvotes: 1
Views: 203
Reputation: 29837
select distinct sub_ser
from sub
where sub_ser in (
select unnest(string_to_array(vms_ser, ',')) from zvm )
this will work well on PostgreSql Database
Upvotes: 1
Reputation: 1051
Firstly, select from "zvm" table and then select separately from "sub" table simply like this-
select distinct sub_ser
from sub
where sub_ser in ('a1','a2','a3')
Upvotes: 0
Reputation: 2399
I think you've to write a procedue to get it done. Take a look at http://forums.mysql.com/read.php?60,78776,148332 . Use a similar procedure specifying ,
as your delimitter to retrieve a1, a2 and a3 seperately and then make your query on table 1.
Upvotes: 0