Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    5

    Unanswered: getting data from two tables

    Hello, hope you can help again one and all. I have two tables in the same db that i need data from but it has to match. ok here it is.
    my first table is named 'system', my second table is named 'burg_site'. I need to get a list from the 'cs_no' field in the table 'system' that has a field 'alt_id' that equals 'RN'.(any alt_id that = RN should give me list of all corresponding 'cs_no' entries). Now I need those cs_no entries to correspond to the cs_no entries in the table burg_site and give me info from the tables
    subscribername, addresscity, addressstate, addresszip,+ order by cs_no.

    cs_no(system) that has alt_id that =RN needs to = cs_no(burg_site) that corresponds to info in fields subscribername, addresscity, addressstate, addresszip all unique ,+ order by cs_no ok? thanks to one and all.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what you're looking for is called a JOIN and every basic SQL tutorial covers it
    Code:
    select burg_site.cs_no
         , burg_site.subscribername
         , burg_site.addresscity
         , burg_site.addressstate
         , burg_site.addresszip
      from system
    inner
      join burg_site
        on burg_site.cs_no = system.cs_no
     where system.alt_id = 'RN'
    order
        by burg_site.cs_no
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2006
    Posts
    5

    thank you

    thank you for the script to my prob. Although I do understand the inner join statement, I couldn't figure out how to get rest of the information based on results from only one table(on burg_site.cs_no = system.cs_no
    where system.alt_id = 'RN') though this is a simple line it was my demon..
    Im still new to this so thank you again
    Last edited by uraslomo; 06-24-07 at 23:05.

Posting Permissions

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