latest reactions

spider
One way is to google for page which cont …
andy
you can find this tool here http://andy. …
Tjarko
Eej Walker, that's pretty cool, I will c …
Walker
Thanks for posting your thoughts. I modi …
Albert
Thanks !! …

Clicky Web Analytics
Use OpenDNS
ZERIGO DNS

Ultimate dns hosting based on pre-defined templates, DNS redirection and lot's more.

mxna feeds

CF101 Archive: September 2007 Object Oriented PizzaJob Opening for ColdFusion Developer at Arizona State UniversityMy New Experience Getting ColdFusion Builder 2 Console WorkingCF101 Archive: February 2007 Data Table GatewaysJob Opening for Sr. ColdFusion Developer in CA/ San Fernando ValleyColdFusion Supports HTTP Verbs PUT And DELETE (As Well As GET And POST)Best wishes for the new FuseboxCF101 Archive: January 2007 Data Access ObjectsOpen Source Conference For CFML DevelopersSkype Blocking Web Services with IIS, ColdFusion & RailoCF101 Archive: October 2006 Five Cool Things with ColdFusionGenerate a tag cloud from an RSS feed with ColdFusionColdFusion MeetUp: Cloudy with a Chance of Tests, with Mike HenkeReminder - Adobe CookbooksCF101 Archive: September 2006 A first look at FusionDebug

All files are strictly confidential: all information is classified.
© Copyright 2002 - 2012 mximize.com.
All right reserved.

Visit Carlos GallupaMXNA webfeed

Multiple conditions in JOIN statement

You can put multiple conditions in your LEFT, RIGHT and INNER/OUTER joins if you want.. below a small example that will give you the idea.

SELECT tbl.id, tblo.naam
FROM sometable tbl
  LEFT JOIN someothertable tblo ON tblo.id = tbl.id
   AND tblo.function = tbl.function
ORDER BY ....

Didn't know this one.. could have saved me a lotta query's in the past :-(

37312 viewed | 10 opinion(s)  | del.icio.us | Digg it | Tjarko @ 01/06/05 0:00 cet


Reactions:

nidhi wrote.... (mail)

it doesnt work !! dont misguide people with such posts!

14 March 2009 16:12 cet  

Tjarkowrote....

It works in sql server and oracle. Its probably your way of coding or your database.

14 March 2009 16:22 cet  

Bio wrote....

multiple conditions on a join is commonplace...or did i miss something?

20 April 2009 15:16 cet  

wese wrote.... (site)

It does work, as long as you know what your doing.
Joining on multiple columns doesn't work properly (5.0).
Adding extra conditions does.

03 June 2009 15:10 cet  

Johny wrote.... (site)

Never tried to join on multiple columns, just with extra condition, but i think also multiple columns should work.

15 October 2009 19:13 cet  

Rahul Anand wrote.... (mail)

Thanks for the nice post. It works for me. I dont know why it is not working for other people..anyway thanks for sharing such a nice post.

06 July 2010 6:39 cet  

ramiro wrote....

off couse it works

30 September 2010 4:58 cet  

Bonzol wrote....

Already knew about this, but yeah it works. And good job telling the world about it. Suprising how many people don't know stuff like this.

10 June 2011 3:49 cet  

Mark wrote.... (site)

Of course it works!I use this in SQL Server 2005/2008 and now I tried it in MySql 5+ and it works great.

Now the challenge is to get it to work in the Zend Framework Zend_Db_Select object.Tell me again why Zend needed to reinvent the wheel and put a layer on top of SQL?I put both conditions in a single string as the joinInner parameter, but it seems like it should be an array, but that doesn't work.Weird.In anyone knows PHP and the Zend Framework, some guidance would be greatly appreciated.

Thanks.

22 September 2011 4:29 cet  

Stephen Brown wrote.... (mail)

God I wish this would work in zend framework too. Managed to produce the select and assemble it out. Runs fine in phpmyadmin when copied in but when zend runs the same select it runs like a where clause. Any attempt to query a null fails as where clases run after the join not during by my account.

03 November 2011 19:09 cet  

Leave your comment

Your name


Your url/website/link/email....


Some room for your reaction is placed here..



The answer to the ultimate question is?? (42 ;-))




URL en mail addresses are translated for you... life sometimes is that simple!!