Monday, November 2, 2009

Keep in mind when using Left Join

The WHERE clause would be false in the following query if tableB.column1 were NULL:

SELECT * FROM tableA LEFT JOIN tableB ON (column1) WHERE tableB.column2=5;

Therefore, it is safe to convert the query to a normal join:

SELECT * FROM tableA, tableB WHERE tableB.column2=5 AND tableA.column1=tableB.column1;

3 comments:

  1. I have visited this blog for the first time. but really very good information. thanks for sharing all the good stuff.

    ReplyDelete
  2. Thank you for information.Los Angeles Web Development Company also provide best service in web development & design.
    Must visit www.newpulsemanagement.com/
    Thank you!

    ReplyDelete
  3. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.Ecommerce Shopping Cart

    ReplyDelete