Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    one more for the nite then bed time, question on Joins

    I think this is working ok (it looks like, the right stuff is showing up, in the right order).
    Not real sure on inner/outer/left and what ever else type of joins, still have some reading to do.
    PHP Code:
    $result mysql_query("SELECT a.ID, a.menu_id, a.submenu_title, a.display_order, b.menu_title, b.display_order FROM page_content as a JOIN menu as b ON (a.menu_id=b.ID) ORDER BY b.display_order,a.display_order",$db); 
    Any way here's my question, I have two fields in the tables that are named the same "display_order" and I cant figure out how to access both from this querry?
    PHP Code:
    $var_menu_title $MyRow['menu_title'];
    $var_submenu_title $MyRow['submenu_title'];
    $var_menu_order $MyRow['display_order']; 
    I am able to get menu_title from table b, submenu_title from table a, but display_order gives me display_order for table b(menu), I would have thought that would give me display_order for table a(page_content). how would I access both display_order fields from the different tables, I would like to list both.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    What you do is give the columns alias names in your select. As in, "SELECT a.display_order as content_order, b.display_order as menu_order". Then in your associative array the index names come out as "content_order" and "menu_order".

    This is also handy for selecting formatted data, like "SELECT date_format(start_date, '%y %m %d') as startdate". Without the alias, the index name becomes "date_format(start_date, '%y %m %d')"... nasty stuff!

  • #3
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fumigator, Thanks much you've been a hugh help the last couple of days.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You're welcome


  •  

    Posting Permissions

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