Multiple Tables Help Needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralph Freshour

    #1

    Multiple Tables Help Needed

    I'm not sure the follow multiple table query is the right way to do
    what I need to do although it seems to be working:

    $php_SQL = "SELECT * ".
    "FROM basics, personal, photos ".
    "WHERE basics.member_n ame = personal.member _name ".
    "AND basics.member_n ame = photos.member_n ame ".
    "AND basics.account_ creation_date >= DATE_SUB(NOW(),
    INTERVAL 30 DAY)";

    I primarily need to return a resultset for all member_names (they are
    index key) filtered for the last 30 days on the
    basics.account_ creation_date - the 30 day thing is working fine.

    I need to access various other table columns (fields) and display this
    data on the web page - member_name is the common key for all tables -
    this all seems to be working fine as I have 8 test records and can
    manually track and see that it is working - the problem is that I need
    to add a 4th table and in doing so, the resultset breaks and returns
    just one record - I am adding an 'online' table with a col called
    is_online which is set to 'yes' if the member is online but the
    following query returns just the one record of the online member:

    $php_SQL = "SELECT * ".
    "FROM basics, personal, photos, online ".
    "WHERE basics.member_n ame = personal.member _name ".
    "AND basics.member_n ame = photos.member_n ame ".
    "AND basics.member_n ame = online.member_n ame ".
    "AND basics.account_ creation_date >= DATE_SUB(NOW(),
    INTERVAL 30 DAY)";

    It seems to me this should be an easy thing to just add the 4th table
    but since this breaks the query now I'm wondering if this query
    structure is even built right?

    Any help would be greatly appreciated...

Working...