LEFT JOIN or use a table OBJECT ? which is better ?

Discussion in 'Databases' started by Maxell, Nov 20, 2007.

  1. #1
    I read this on some forums that I dont remember, there was quite a debate on this, an anyone please telle me which is a good approach to get information fron different tables for example I write code like this..

    suppose I have 2 tables, user, and images

    mysql_query("SELECT * FROM users us, images im WHERE blah blah ");

    now this works fine, I have created objects of thse tables to fetch information from 2 tables, but I have seen people using LEFT JOIN or any other join to accomplish this, whats the difference ? which is fast ? which puts more load on server ? any quick explanation ?

    thanks..
     
    Maxell, Nov 20, 2007 IP
  2. Kynlem

    Kynlem Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    SELECT ... FROM a, b WHERE b.some_field = a.some_field is a not standard syntax for inner joins, although it has been historically used by most of the database systems.

    Personally, I prefer standards-compliant syntax: SELECT ... FROM a INNER JOIN b ON b.some_field = a.some_field.

    Google for "A Visual Explanation of SQL Joins" for a simple demonstration of SQL joins using Euler diagrams.
     
    Kynlem, Nov 20, 2007 IP