help with JOIN

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graham Mattingley

    #1

    help with JOIN

    Hi Group,

    I have three tables for a mailing list app I am trying to right... I want to try and avoid running 3 selects inside eachother..

    The LIST table is a list of people what have registered for news letters, the newsletters table is a list of newsletter available, and the news list joins them up. I am trying to display the newsletters.new sletter_name for every list.id line.. So I would like to be able to say list.first_name , list.last_name has subscribed to newsletters.new sletter_name. I am not really sure this is possible as I would like to loop through the list RS as well as the newsletter RS set...

    Anyway any ideas ???

    describe list;
    +------------+-----------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+-----------------------+------+-----+---------+----------------+
    | id | mediumint(8) unsigned | | PRI | NULL | auto_increment |
    | name_last | varchar(20) | YES | | NULL | |
    | name_first | varchar(20) | YES | | NULL | |
    | email | varchar(50) | YES | | NULL | |
    | password | varchar(20) | YES | | NULL | |
    | url_dir | varchar(10) | YES | | NULL | |
    | format | varchar(4) | YES | | NULL | |
    | date_in | timestamp(6) | YES | | NULL | |
    +------------+-----------------------+------+-----+---------+----------------+
    8 rows in set (0.09 sec)

    mysql> describe newslist;
    +------------+-----------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+-----------------------+------+-----+---------+----------------+
    | id | mediumint(8) unsigned | | PRI | NULL | auto_increment |
    | member | mediumint(9) | YES | | NULL | |
    | newsletter | mediumint(9) | YES | | NULL | |
    +------------+-----------------------+------+-----+---------+----------------+
    3 rows in set (0.02 sec)

    mysql> describe newsletters;
    +-----------------+-----------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +-----------------+-----------------------+------+-----+---------+----------------+
    | id | mediumint(8) unsigned | | PRI | NULL | auto_increment |
    | newsletter_name | varchar(50) | YES | | NULL | |
    | island_id | tinyint(4) | YES | | NULL | |
    | resort_id | smallint(6) | YES | | NULL | |
    +-----------------+-----------------------+------+-----+---------+----------------+
Working...