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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. table join

table join

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.
  • N Offline
    N Offline
    netJP12L
    wrote on last edited by
    #1

    Hi guys. i want join the results this table below with matching records of another table. How could i do it. I have tried using the right join on class table but seems like not getting the right results. could you hlep me joining the class table with all all those records are only in class table. Thanks select ucv.cf_value+', '+ucv2.cf_value as FullName from users u left join CUSTOM_FIELDS_VALUE ucv on ucv.cf_id=3 left join CUSTOM_FIELDS_VALUE ucv2 on ucv2.cf_id = 2 right join class on class.instructorName= ucv.cf_value+', '+ucv2.cf_value where u.uid=ucv.uid and u.uid=ucv2.uid order by ucv.cf_value+', '+ucv2.cf_value asc

    M 1 Reply Last reply
    0
    • N netJP12L

      Hi guys. i want join the results this table below with matching records of another table. How could i do it. I have tried using the right join on class table but seems like not getting the right results. could you hlep me joining the class table with all all those records are only in class table. Thanks select ucv.cf_value+', '+ucv2.cf_value as FullName from users u left join CUSTOM_FIELDS_VALUE ucv on ucv.cf_id=3 left join CUSTOM_FIELDS_VALUE ucv2 on ucv2.cf_id = 2 right join class on class.instructorName= ucv.cf_value+', '+ucv2.cf_value where u.uid=ucv.uid and u.uid=ucv2.uid order by ucv.cf_value+', '+ucv2.cf_value asc

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Oh dear have you got a problem. Looks like you are using the instructors name as a key field for joining tables - WRONG. Each table should have an ID field (usually and int IDENTITY(1,1)) as the primary key and then a foreign key to maintain data integrity. Your join structure is wrong. A left join to UCV2 and THEN a right join the to class means that you will get records, wait I'm have no idea what you would get but it would be a mess. Take a look at this Visual Representation of SQL Joins[^] for some clarification

      Never underestimate the power of human stupidity RAH

      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