SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    Toronto
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    optimizing these queries into one?

    Hi guys,

    Here's my SQL (stripped of all PHP code)

    PHP Code:

    $mQuery 
    db_query("SELECT DISTINCT manufacturer FROM kcs_threads ORDER BY manufacturer"); while ($mResult db_fetch($mQuery)) {
     
                    
    //HTMl here
     
                    
    $query "select t.type, t.newUrlType, g.threadType, g.groupName, g.groupNameUrl
                    FROM kcs_threads t LEFT JOIN kcs_threadgroups g ON t.type = g.threadType
                    WHERE t.manufacturer = "
    .escapeQuote($mResult['manufacturer'])."
                    ORDER BY t.type, g.groupName"
    ;
     
                    
    $result db_query($query);
     
                    while(
    $thread db_fetch($result)) {
     
                                    
    //If validations and HTML display here
     
                    
    }

    Hard to explain WHAT I am trying to do. Can I post Table data to illustrate better?

    Thanks

    Aaron

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    rudy.ca | @rudydotca
    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
  •