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 |
|
tclose
Starting Member
24 Posts |
Posted - 2010-04-22 : 23:29:58
|
| I have 11 tables in one database that have identical columns. They each have a column named 'Account' which is the primary key, but no foreign keys. I want to write a single query that will display all of the data row by row from each table. I tried the following, but this tries to place all of the columns from different tables on the same row. Any advice is appreciated.SELECT a.*,b.*,c.*,d.*,e.*,f.*,g.*,h.*,i.*,j.*,k.*FROM Assets a, Department b,Purchases c,Sales d,Expenses e,Liabilities f,Inventory g,Profit h,Payroll i,SalesReturns j,Vendors k |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-22 : 23:32:38
|
that will give you a CROSS JOIN and give you very bad performance.You want the record from each table to appear in same row ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
tclose
Starting Member
24 Posts |
Posted - 2010-04-22 : 23:36:15
|
quote: Originally posted by khtanYou want the record from each table to appear in same row ?
No. I just want the tables to lay out as they are row by row - as if I selected all columns from only one table |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-22 : 23:42:24
|
you have to use a separate select query for each table KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
tclose
Starting Member
24 Posts |
Posted - 2010-04-22 : 23:47:55
|
quote: Originally posted by khtan you have to use a separate select query for each table KH[spoiler]Time is always against us[/spoiler]
Ok - I was hoping that wasn't the case, but it is what it is - thanks for the information. |
 |
|
|
|
|
|
|
|