in reply to Re: joining tables with SQL::Abstract
in thread joining tables with SQL::Abstract
I just changed it into a string reference (e.g. \" = drivers.userid")
But this strategy fails if you want to look for a key field. For example, to obtain the following query:
SELECT drivers.username FROM users, drivers WHERE users.userid=drivers +.userid AND users.userid=1000
You should do something like:
my($stmt2, @bind2) = $sql->select("users, drivers", ["drivers.username"], { "users.userid" => 1000, "users.userid" => \"= drivers.userid"} # <- Overrides + previous "users.userid" key );
But you end up with 2 identical keys in the anonymous hash and the second will override the first. Yes, one solution is to swap the (key,value) pair in last hash entry to drivers.userid => \"= users.userid", but for doing that automatically (that's the point for using SQL::Abstract after all) I must check all possible keys in the WHERE clause.
Is there a way to overcome this?
Thanks in advance
citromatik
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: joining tables with SQL::Abstract
by larryl (Monk) on Nov 19, 2008 at 17:32 UTC |