Results 1 to 5 of 5

Thread: JOIN queries

  1. #1
    Join Date
    Mar 2004
    Location
    Fresno, Ca
    Posts
    2

    JOIN queries

    I have been told by one person that in order to draw records from two tables, I have to do a join query like this:

    <cfquery name="getarticles" dsn="mydsn">
    SELECT a.articleid, a.articletitle, a.articleauthor, a.articlecontent, a.articlepdf, a.subjectid, s.subjectname
    FROM tblarticles a
    INNER JOIN tblsubjects s ON a.subjectid = s.subjectid
    </cfquery>
    But another person said to do it this way:

    <cfquery name="articles" datasource="mydsn">
    SELECT subject.sID, subject.sName, article.aID, article.aTitle, article.aAuthor, article.aContent, article.aPDF, article.sID
    FROM subject, article
    WHERE subject.sID = #URL.variable#
    AND subject.sID = article.sID
    ORDER BY subject.sID ASC
    </cfquery>
    Does it really make a difference? Do they both do the same thing, and it is a matter of preference? Or is their some functionality innate in one that is not accessible using the other?

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    Yes. Both are same. One is ANSI - SQL Syntax which is becoming a standard.

  3. #3
    Join Date
    Mar 2004
    Location
    Fresno, Ca
    Posts
    2
    Could you tell me which one is ANSI?

    Where can I learn about that syntax?

    Thanks a lot!

  4. #4
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Advantage of ANSI joins becomes more evident if you are using OUTER JOINs, it is more elegant and less prone to error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •