Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mohdmartin
Starting Member
22 Posts |
Posted - 2007-09-17 : 05:57:13
|
| I create following tables.employee table------------------------EMP_ID varcharNAME varcharDEPARTMENT_CODE intPOSITION_CODE intCOUNTRY_CODE intdepartment table------------------DEPARTMENT_CODE intDEPARTMENT_NAME varcharposition table---------------POSITION_CODE intPOSITION_NAME varcharcountry table-------------COUNTRY_CODE intCOUNTRY_NAME varcharIn employee table I have to store two country names. ie. employee currently working in this countrybut his home country name (origin country) is anothername. In country table all countries information available.ie. country_code and country_name.How I can design the employee table that it get country_name from COUNTRY TABLE ?but we can not use same country_code in two fields.ORotherwise I will have to create employee table like thisemployee table------------------------EMP_ID varcharNAME varcharDEPARTMENT_CODE intPOSITION_CODE intCOUNTRY_CODE intCOUNTRY_NAME varcharie. during data entries direct insert the country_name in employeetable ?I want to create separate table for separate data.department,postion,country.How I can use unique country_code in employee table's twofields ?regardsMartin |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-09-17 : 11:29:00
|
I would have two columns in the EMPLOYEE table:WORK_COUNTRY_CODEORIGIN_COUNTRY_CODEand join each of these to the same COUNTRY table:SELECT *FROM EMPLOYEE LEFT OUTER JOIN COUNTRY AS WC ON WC.COUNTRY_CODE = WORK_COUNTRY_CODE LEFT OUTER JOIN COUNTRY AS OC ON OC.COUNTRY_CODE = ORIGIN_COUNTRY_CODE Kristen |
 |
|
|
mohdmartin
Starting Member
22 Posts |
Posted - 2007-09-18 : 04:07:48
|
| Thanks you very much,it is very helpfullMartin |
 |
|
|
|
|
|