SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Optimizing...

  1. #1
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Optimizing...

    Code:
    SELECT
    	m.title, m.header, m.metak, m.metad, 
    	d.body,
    	o.allow_php, o.publish_status, o.view_status 
    FROM 
    	cs_content_main as m, 
    	cs_content_data as d, 
    	cs_content_options as o 
    WHERE 
    	m.id = '{$Content_Id}' 
      AND 
      	m.id = d.id 
      AND 
      	m.id = o.id
    Is there a better way to write this? and/or optimize it?

    - Eric
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your tables are not indexed changing that would help your query, other than that it looks fine.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    if you can have a main without options, you might want to consider a LEFT OUTER join instead of the inner join you have there
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937
    if you can have a main without options, you might want to consider a LEFT OUTER join instead of the inner join you have there
    And how would that look?
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Code:
    select m.title, m.header, m.metak, m.metad
         , d.body
         , o.allow_php, o.publish_status, o.view_status 
      from cs_content_main as m
    inner
      join cs_content_data as d
        on m.id = d.id 
    left outer
      join cs_content_options as o 
        on m.id = o.id
     where m.id = '{$content_id}'
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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