SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do I optimize this?

    Hey, how's it going? I'm very weak in my command of sql. How would I optimize the following...
    PHP Code:

    $firstquery 
    mysql_query("SELECT * FROM blogs ORDER BY id DESC LIMIT 0,20" );
    while(
    $row mysql_fetch_array($firstquery)) {
         
    $toomanyqueries mysql_fetch_array(mysql_query("SELECT * FROM members m, profiles p WHERE m.userid='$nurow[userid]' AND m.userid=p.userid" ));
         echo 
    "$toomanyqueries[a lot of different stuff...]";
    }
    ?> 
    Basically, I would like to combine the $firstquery and $toomanyqueries into 1 query. The script is for my weblogging site. Its function is to extract the last 20 members who posted an entry, then output some info about them. However, the info is in different tables and such. For the "profiles" and "members" tables, each member has only one row. However, for the "blogs" table, each weblog entry is entered as a new row. So, for this case, there will be many rows associated with a given member.

    Thanks in advance! Let me know if what I've said is unclear and confusing (I tend to be that way.. heh).

  2. #2
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    NJ/NY
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind. Got it.


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
  •