Results 1 to 4 of 4
  1. #1

    MySQL, 2 querys in one, and order results in groups.

    Hi, Iím trying to select links from certain category's. The categories are in the category table and the links and in the links table. I want to query the database to order the groups by the "order" column in the table and order the links into the respective group alphabetically. I want to do this in 1 MySQL query.
    PHP Code:
    "SELECT category, order FROM category WHERE active = '1'";
    $query "SELECT name, url, category FROM links WHERE menu = '1'";

    // Show All groups in there specified orders 1 being at the top.
    // Alphabetically order links in there respective groups.
    This should then output something like this:
    <div><b>Group Number 1</b><br>
    <a href="">AltaVista</a><br>
    <a href="">MSN</a></div><br>
    <div><b>Another Group</b><br>
    <a href="">Google</a><br>
    <a href="">Lycos</a>
    <a href="">Yahoo</a></div><br>
    So i need to know how to do that in one query and how to order the groups and display the links within the groups aphabetically
    Thanks in Advance,
    MSN: [email protected]

  2. #2
    Join Date
    Sep 2002
    Post the structure of both tables, then we will see
    How's my programming? Call 1-800-DEV-NULL

  3. #3
    Ok, I have attatched an example of the table structure, as i dont know how to use <pre> in forums.

    Attached Files Attached Files
    MSN: [email protected]

  4. #4
    Join Date
    Sep 2002
    SELECT category.*, links.* FROM category, links WHERE = $category AND ORDER BY category.order ASC, ASC

    $category is your category number
    How's my programming? Call 1-800-DEV-NULL

Posting Permissions

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