This is a discussion on select 3 values from one table to return in one rs within the SQL Server forums, part of the Microsoft SQL Server category; --> I am having trouble accessing a table and am seeking out some advise on how to do it. I ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am having trouble accessing a table and am seeking out some advise on how to do it. I have a select statement that joins several tables and everything works ok , however I want to access a further table to retrieve 3 rs values, so basically I want to retrieve 3 values from the same table - identifying each by a value in that table. Any help or pointer would be very welcome. Simon Christie strSearch is a dynamically created search string Copy of select statement below sql = "SELECT Master.Master_Key,Master.First_App,Original_Info_D ate,Last_Info_Date,Area.Area_Name AS Area_Name, State_Cntry.State_Cntry_Name, Company.Oper_Name1 AS Oper_Name1, Company.Oper_Name2 AS Oper_Name2, " _ & " Company.Oper_Name3 AS Oper_Name3, Location.City AS City, Projects.Project_Name AS Project_Name, " _ & " Expansion.Expansion_Code AS Expansion_Code, Master.Cap_Size AS cap_size, Cap.Cap_Unit AS Cap_Unit, Master.Cost AS Cost, " _ & " Master.Status AS Status, Master.Estimated_Year_Completed AS Estimated_Year_Completed " _ & " FROM Master INNER JOIN " _ & " Area ON Master.Area_Key = Area.Area_Key INNER JOIN " _ & " Company ON Master.Company_Key = Company.Company_Key INNER JOIN " _ & " Location ON Master.Location_Key = Location.Location_Key INNER JOIN " _ & " Expansion ON Master.Expansion_Key = Expansion.Expansion_Key INNER JOIN " _ & " Cap ON Master.Cap_Key = Cap.Cap_Key INNER JOIN " _ & " Projects ON Master.Project_Key = Projects.Project_Key INNER JOIN " _ & " State_Cntry ON Location.State_Cntry_Key = State_Cntry.State_Cntry_Key " _ & " WHERE " & strSearch _ & " ORDER BY Area.Area_Key, State_Cntry_Name,Oper_Name1,City" The table I need to access is called LEC LEC_Key (PK) Master_Key - Database Master Key Company_Key - matches the company LEC_Type_Key - 3 types per company (values L,E or C) Each Master Key will have 3 values in the table, one each of L,E and C Hope this makes some sort of sense Thanks in advance Simon Christie |