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 |
Palermo
Starting Member
25 Posts |
Posted - 2013-10-24 : 19:14:24
|
I have tried :SELECT column_name1, column_name2, column_name3FROM tbl_name1, tbl_name2, tbl_name3WHERE tbl_name1.column_name = tbl_name2.column_name AND tbl_name2.column_name = tbl_name3.column_nameAlthough the query runs there is no data. The column is table 3 has numerical data (int) whereas the columns in the other two tables are nchar(20). is this why I get no data or is there something wrong with my syntax? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-10-24 : 23:24:02
|
SELECT column_name1, column_name2, column_name3FROM tbl_name1join tbl_name2 on tbl_name1.column_name = tbl_name2.column_name join tbl_name3 on tbl_name2.column_name = convert(nchar(20), tbl_name3.column_name)Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
Palermo
Starting Member
25 Posts |
Posted - 2013-10-25 : 13:20:10
|
I wasn't getting any data as I wasn't joining tables on their shared foreign and primary keys.SELECT table1.column, table2.column, table3.columnFROM table1, table2, table3WHERE table1.column = table3.column [on their shared primary key]AND table3.column = table2.column [on their shared foreign key] |
|
|
markjosol
Starting Member
2 Posts |
Posted - 2013-10-26 : 05:06:43
|
is table 3 has numerical data (int) whereas the columns in the other two tables are nchar(20). is this why I get no data or is there something wrong with my syntax?________________________________________________http://www.fifautc.com/markjosol josol |
|
|
|
|
|