cosmicperl has asked for the wisdom of the Perl Monks concerning the following question:

Or should that be Getting SQL out of DBIC? 
Hi All,
  I've got this SQL, but I can't find the DBIC way of doing it...
SELECT t1.id, t1.name, t2.uid FROM table1 t1 LEFT JOIN table2 t2 ON t1.id = t2.tid AND t2.uid = 22 ORDER BY t2.uid DESC, t1.name
I've got 2 tables, the first has a long list of names with id, the second has some of those id's against another unique id. I want to list off of the names from the first table, but have ones that appear for a set uid listed at the top.

I can't seem to find any examples online of JOINS with multiple things in the ON clause. I'm not even sure what you'd call this.

Having the t2.uid = 22 as part of a WHERE clause instead only gives me those rows that have a matching row in table2...

Lyle

Replies are listed 'Best First'.
Re: Getting SQL into DBIC...
by tweetiepooh (Hermit) on Jul 15, 2009 at 11:46 UTC
    I'm not in a place where I can test or prove this but could you use a union statement
    select where uid = <value> union select where uid != <value>