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 |
mcbulan
Starting Member
7 Posts |
Posted - 2010-09-01 : 09:34:37
|
Hello allI have 5 tables which has same colunms and column names. i would like to select from these tables in a same select query.Please look at the tables : dep_chemistry : kid, name,surname,email,activedep_civileng : kid, name,surname,email,activedep_electronics : kid, name,surname,email,activedep_medical : kid, name,surname,email,activedep_mechanical : kid, name,surname,email,activei would like to create a select command that select from all these tables in one query.just like : "select kid,name from dep_chemistry,dep_civileng,dep_electronics,dep_medical,dep_mechanical where active = 1"mcb |
|
CSears
Starting Member
39 Posts |
Posted - 2010-09-01 : 09:41:17
|
If the tables are Identical you can use the UNION or UNION ALL statement.select kid,name from dep_chemistry where active = 1UNIONselect kid,name from dep_civileng where active = 1UNIONselect kid,name from dep_electronics where active = 1UNIONselect kid,name from dep_medical where active = 1UNIONselect kid,name from dep_mechanical where active = 1 |
 |
|
mcbulan
Starting Member
7 Posts |
Posted - 2010-09-01 : 10:26:00
|
thank you very much for help CSears.mcb |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-01 : 10:40:57
|
Probably a little advanced but you could make a view over the tables. Looks like it's already set up for partitioning.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|