-
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?
-
Yes. Both are same. One is ANSI - SQL Syntax which is becoming a standard.
-
Could you tell me which one is ANSI?
Where can I learn about that syntax?
Thanks a lot!
-
-
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
-
Forum Rules
|
|