SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    pt
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problem displaying data from 2 tables

    Hi,

    I want to display data from 2 tables.
    Something like:

    Goals:
    category_goal1:
    1. goal 1
    2. goal 2
    category_goal2:
    1. goal 3
    2. goal 4
    category_goal3:
    1. goal 5
    2. goal 6

    I made 2 tables:

    Goals:
    ID int(11) auto_increment
    cat_goal_ID int(11)
    order_goal int(11)
    goal - mediumtext

    and

    cat_goals
    cat_goal_ID int(11) auto_increment
    cat_goal

    Everything is ok, i can display (or have available) the data from the 2 tables like this:

    SELECT *
    FROM goals, cat_goals
    WHERE goals.cat_goal_ID = cat_goals.goals_ID AND cat_goals.cat_goal_ID = 1
    ORDER BY `order_goal` ASC

    I would made a query for each category i have, but new added categories woudn't show up, of course.

    Is there a way to display all the data and the new added categories?

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    could you repeat the question please?

    your sample sql does not appear to match your table layouts

    if you are only getting category 1 it's because you are filtering for only that category
    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
  •