Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Getting SQL into DBIC...

by cosmicperl (Chaplain)
on Jul 15, 2009 at 11:23 UTC ( [id://780264]=perlquestion: print w/replies, xml ) Need Help??

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>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://780264]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-05-19 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found