Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Need some help with SQL Join statements please

Need some help with SQL Join statements please

Scheduled Pinned Locked Moved Database
helpdatabasecomquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarkB777
    wrote on last edited by
    #1

    Hi, I have 3 tables. 1. A contact table 2. A company table 3. A company to contact association table. If a company to contact association is created, a field, 'CompanyName', in the contact table needs to contain the name of that company (in order for our mailing lists to print correctly). I've been trying to write a query which will fill in all of the contact table 'CompanyName' values, with all of the corresponding values in the company table. The company to contact association table is the link between the two so: 1. I need to determine which contact's have an association with a company 2. I need to get the companyID from the association table, and get the company name 3. I need to set the contact company name to the retrieved value. Only problem is... IM STUCK!!! This is what i've done so far. SELECT Contacts.CompanyName FROM MarkSandpit.dbo.Contacts INNER JOIN MarkSandpit.dbo.Associations_Companies_to_Contacts ON Contacts.mxContactID = Associations_Companies_to_Contacts.mxContactID INNER JOIN mxContact.dbo.Companies ON Associations_Companies_to_Contacts.mxCompanyID = Companies.mxCompanyID This just gives me a list of all the company names in the contact table, which have associations with a company. Could some please help me out? Cheers,

    Mark Brock "We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen Click here to view my blog

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups