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. Multiple columns

Multiple columns

Scheduled Pinned Locked Moved Database
2 Posts 2 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.
  • J Offline
    J Offline
    Jaydeanster
    wrote on last edited by
    #1

    Hello, Please advise on how I might be able to make this sproc work... declare @TrainerID int select TrainerID, LastName, FirstName, City, State, Country, r.code, l.description, p.Code from trainers as t inner join Regions as r on t.region = r.regionid inner join Languages as l on t.Language1 = l.LangID --and t.Language2 = l.LangID --and t.Language3 = l.LangID inner join products as p on t.product1 = p.ProductID --on t.product2 = p.ProductID --on t.product3 = p.ProductID --on t.product4 = p.ProductID where TrainerID = @TrainerID The situation is that I have designed in the Trainers (t) table multiple columns of Languages and Products with properties as Int which stores values based on their respective LanguageID and ProductID from the Languages and Products (definition) table. The dilemma is on the result, I would like to see the actual codes and not the ID key of each of the multiple columns coming from the definition tables. Thanks Jay Feng Screwed - the art of moving to a new place because the old place is just too messy to clean.

    C 1 Reply Last reply
    0
    • J Jaydeanster

      Hello, Please advise on how I might be able to make this sproc work... declare @TrainerID int select TrainerID, LastName, FirstName, City, State, Country, r.code, l.description, p.Code from trainers as t inner join Regions as r on t.region = r.regionid inner join Languages as l on t.Language1 = l.LangID --and t.Language2 = l.LangID --and t.Language3 = l.LangID inner join products as p on t.product1 = p.ProductID --on t.product2 = p.ProductID --on t.product3 = p.ProductID --on t.product4 = p.ProductID where TrainerID = @TrainerID The situation is that I have designed in the Trainers (t) table multiple columns of Languages and Products with properties as Int which stores values based on their respective LanguageID and ProductID from the Languages and Products (definition) table. The dilemma is on the result, I would like to see the actual codes and not the ID key of each of the multiple columns coming from the definition tables. Thanks Jay Feng Screwed - the art of moving to a new place because the old place is just too messy to clean.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Use multiple inner joins ... INNER JOIN Languages as l1 ON t.Language1 = l1.LangID INNER JOIN Languages as l2 ON t.Language2 = l2.LangID INNER JOIN Languages as l3 ON t.Language3 = l3.LangID ...etc.


      My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      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