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 |
|
jdub_92
Starting Member
13 Posts |
Posted - 2008-10-18 : 03:44:17
|
| Hi,I want to join two tables, but there is no relation between them,table1vendorid CHAR(5),companyname VARCHAR(30),repfname VARCHAR(20),replname VARCHAR(20),referredby CHAR(5)table2Col1 int,Col2 varchar(10),Col3 datetimehow can i join them?, is it possible?thanks,jwill |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-18 : 04:12:20
|
its possible. but you will get result as cartesian product of them unless you've a linking field b/w them .use like belowSELECT *FROM table1CROSS JOIN table2 not sure if you're lookinmg for this |
 |
|
|
malaytech2008
Yak Posting Veteran
95 Posts |
Posted - 2008-10-18 : 23:30:37
|
| Joining two tables without relation is meaningless.Even if joining two tables it results a cartesian product of two tables.malay |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-19 : 02:53:13
|
quote: Originally posted by malaytech2008 Joining two tables without relation is meaningless.Even if joining two tables it results a cartesian product of two tables.malay
Not always. what if you just want all combinations of values from both table. Consider case when one table contain month details and other day details. you may take cross join with them while generating a calendar table. such cases it do make sense. |
 |
|
|
jdub_92
Starting Member
13 Posts |
Posted - 2008-10-19 : 06:23:00
|
| actually what i want is to know all the columns data type,what data type is available also in the other table,.by cross joining i can be able to know it,.what i want to do now is seperate columns that are not in the other table or same data type.,sample scenariotable1vendorid CHAR(5),companyname VARCHAR(30),repfname VARCHAR(20),replname VARCHAR(20),referredby CHAR(5)table2Col1 int,Col2 varchar(10),Col3 datetimeresult 1:Col2 varchar(10), companyname,repfname,replname = match data typeresult 2:Col1 int, Col3 datetime, vendorid, referredby char(5) = without matchsyntax:SELECT *FROM table1CROSS JOIN table2problem now is how to achieve those result..how can i seperate those?jwill |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-19 : 06:47:02
|
| nope. you cant match datatypes using cross join. it takes only data from tables. for datatype matching, you need to make use of catalog view INFORMATION_SCHEMA.COLUMNS. It contain data type information of each column in tables of a db. |
 |
|
|
|
|
|
|
|