[Dbix-class] join to tables has two "identical" columns
nhyda
nhydanhyda at gmail.com
Thu Mar 18 18:40:18 GMT 2010
I am trying to use DBIx::Class in Catalyst
Here is my problem.
I have two tables as shown below
Table 1 Table 2
id name id left right
1 A 1 A B
2 B 2 B C
3 C 3 C D
4 D 4 A E
5 E 5 B E
I want to list who is B's neighbor.
result expected
1 A
2 C
3 E
I have two has_many relationship defined in Table 1
__package__->has_many ("at_left","DB::Table2",{left=3D
>"name"})
__package__->has_many ("at_right","DB::Table2",{right=3D>"name"})
and corresponding belongs_to in Table 2
I want to do something like
select name from table 1 as t1
join table 2 as t2 on t1.name =3D t2.left or t1.name =3D t2.right
How do I put it into model(DB::Table1) ->search ?
any help or idea is appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100318/86d=
49b77/attachment-0001.htm
More information about the DBIx-Class
mailing list