in reply to Combining two fetches with DBI and MySQL

It's easier to do this in SQL and not in Perl.

You need to do an outer join between the two tables.

select t1.name, t2.name from t1 left outer join t2 on t1.name = t2.name

You'll get back a two column result set. If a name is in both tables then it will appear in both columns. If it only appears in t1 then the second column will contain NULL.

You then need to write the Perl that handles that and creates your list.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^2: Combining two fetches with DBI and MySQL
by bangers (Pilgrim) on Aug 09, 2006 at 14:30 UTC
    A good solution, but it assumes that table 2 is a subset of table 1. This may be true, but is not explicitly said, So if in the above example table 2 also contained 'brian', then 'brian' would be missing from the output. The addition of a union would fill in any rows in table 2 but not in table 1
    select t1.name, t2.name from t1 left outer join t2 on t1.name = t2.name union select t2.name, t1.name from t2 left outer join t1 on t2.name = t1.name where isnull(t1.name)