SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Location
    new jersey
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Another PHP question

    I have this query which orders all of the entries by MerchID.

    if($result = $db->query_return("SELECT deal.merchID, deal.coupon, deal.expires, deal.expDate, deal.description FROM deals deal, deal_cats deal_cat WHERE deal_cat.catID='$c' AND deal_cat.dealID=deal.dealID ORDER BY deal.merchID"))

    I would like to order the entries alphabetically by name which is in the merchants table.

    The query above is only pulling from the deals table. Any idea how I can do this?

    Thanks
    I need a logo. Submit here.

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mantra
    I have this query which orders all of the entries by MerchID.

    if($result = $db->query_return("SELECT deal.merchID, deal.coupon, deal.expires, deal.expDate, deal.description FROM deals deal, deal_cats deal_cat WHERE deal_cat.catID='$c' AND deal_cat.dealID=deal.dealID ORDER BY deal.merchID"))

    I would like to order the entries alphabetically by name which is in the merchants table.

    The query above is only pulling from the deals table. Any idea how I can do this?

    Thanks

    Without knowing more of your database structure, I can only guess, but:
    Code:
    SELECT 
       deal.merchID, 
       deal.coupon, 
       deal.expires, 
       deal.expDate, 
       deal.description 
    FROM 
       deals deal, 
       deal_cats deal_cat 
    LEFT JOIN
        merchants merch 
    ON 
       deal.merchID = merchants.merchID
    WHERE 
       deal_cat.catID='$c' 
    AND 
       deal_cat.dealID=deal.dealID 
    ORDER BY 
       merch.merchName
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Member
    Join Date
    Dec 2001
    Location
    new jersey
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, did not work ..
    I need a logo. Submit here.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Care to give a more detailed explaination? What errors were encountered?


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
  •