List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:May 24 2006 4:52pm
Subject:Re: Noob: Converting to Inner Join
View as plain text  
 >Are there any advantages to converting this 'working' query below to
 >use INNER JOIN ?
 >If so, what would the correct syntax be ?
 >
 >SELECT category.name, page.name, content.title, content.body
 >FROM category, page, content
 >WHERE content.page_id = page.id
 >AND page.category_id = category.id
 >AND category.id =1
 >ORDER BY content.order_id ASC
 >LIMIT 0 , 30

Explicit INNER JOINs are easier to read, easier to debug, and since 
5.0.12 always preferable in MySQL for reasons given at 
http://dev.mysql.com/doc/refman/5.1/en/join.html (look for '5.0.12').

SELECT category.name, page.name, content.title, content.body
FROM category
INNER JOIN content USING (category_id)
INNER JOIN page USING (page_id)
WHERE category.id = 1
ORDER BY content.order_id ASC
LIMIT 0 , 30

PB



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.7.1/347 - Release Date: 5/24/2006

Thread
Noob: Converting to Inner JoinGraham Anderson24 May
  • Re: Noob: Converting to Inner JoinChris Sansom24 May
    • Re: Noob: Converting to Inner JoinGraham Anderson24 May
    • Re: Noob: Converting to Inner JoinPeter Brawley24 May
      • Re: Noob: Converting to Inner JoinChris Sansom24 May
        • Re: Noob: Converting to Inner JoinPeter Brawley24 May