sql server - Create 3 tables from 1 table in mssql -


I am creating a database of horse racing data, data is net-to-net, excel, and then a table in a MS SQL database < Code> Race_Master .

The column includes such data:

  date status barriers horsename trainname jockeyname  many 

Of course, horses, jockeys and trainers The name is stored in an inefficient and non-relational way, see the btnby entry being repeated. So I have created 3 new tables:

  horse_name trainer_name jockey_name  

none of those tables are duplicates

I now , A new table which will take data from Race_Master and instead of using horse trainers and jockey names, how can you see those related tables and use their IDs as a reference?

If you have already created a table .....

 Select NewTable (MasterID, JockeyID, TrainerID, HorseID) to insert M.MasterID, J.JockeyID, T.TrainerID, Race_Master M from H.HorseID from inside M.JockeyName = J.JockeyName Insider on Jockey J Join Trainer T on M.TrainerName = T.TrainerName Insider Join H. HorseName = H.HorseName  

If you want to immediately create a table,

  M.MasterID, J.JockeyID, T.TrainerID, H.HorseID Investigation New_Table selection from Race_Master M inside Jockey J Join M.JockeyName = J.JockeyName Insider Join Trainer T on M.TrainerName = T.TrainerName Insider M.HorseName = H.HorseName on Horse H  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -