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 |
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-07-06 : 11:23:12
|
Ok. Maybe this is a better example of what I am trying to do. Select id, Location_Code, Responsibility_Begins_With, Approver_Main, AppMain_UserId, Approver_BackUP,AppBackUp_UserIdFrom Approver_Matrixwhere Responsibility_Begins_With like 'DR 200% Super User'Select Application_Name, Responsibility_Key, Responsibility_Name from responsibilitiesWhere Responsibility_Name like 'DR 200% Super User' -----------------------------I need to select this Two Tables: approver Matrix and Responsibilities. But instead of union all Vertical. I need to have this two selection side by side. So it will look something like this:Select id, Location_Code, Responsibility_Begins_With, Approver_Main, AppMain_UserId, Approver_BackUP,AppBackUp_UserId,Application_Name, Responsibility_Key, Responsibility_Name From Approver_Matrix and from responsibilitieswhere Responsibility_Begins_With like 'DR 200% Super User'Were Responsibility_Name like 'DR 200% Super User' Thank you for the help!!! |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-07-06 : 11:36:30
|
Will Responsibility_Begins_With and Responsibility_Name have the same values? Can we join both those tables based on these fields...if yes, try thisSELECT a.id, a.location_code, a.responsibility_begins_with, a.approver_main, a.appmain_userid, a.approver_backup, a.appbackup_userid, b.application_name, b.responsibility_key, b.responsibility_name FROM approver_matrix a INNER JOIN responsibilities b ON a.responsibility_begins_with = b.responsibility_name WHERE a.responsibility_begins_with LIKE 'DR 200% Super User' |
 |
|
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-07-06 : 12:08:22
|
| Thank you vijayisonly. I think I should it give you an example of data for each table. You see the problem is that this two tables don't have anything in common except the fact that both of them query out the results based on 'DR 200% Super User'Bothe IMPORTANT they don't have anything in common, there is not any column that you can join it under. This is why I wanted to merge both tables based on their result using :Select Application_Name, Responsibility_Key, Responsibility_Name from responsibilitiesWhere Responsibility_Name like 'DR 200% Super User' As Main TableThanks for the help |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-07-06 : 12:12:34
|
| Can you show us the values in columns Responsibility_Name and Responsibility_Begins_With ....if u are able to use LIKE on both these fileds..you should be able to join them. If you show us the data , it'll help |
 |
|
|
osirisa
Constraint Violating Yak Guru
289 Posts |
Posted - 2009-07-06 : 12:38:17
|
Approver Table ResultsSelect id, Location_Code, Responsibility_Begins_With, Approver_Main, AppMain_UserId, Approver_BackUP,AppBackUp_UserIdFrom Approver_Matrixwhere Responsibility_Begins_With like 'DR 200% Super User'id----location--Resp_begin_With-----------Approver Name -------Approverid-------BackUp_name-----------BackUp_id 1 200 DR 200% Super User Jean Marc Lombrez xxoxoxox Jean-Luc Richard xoxoxoxoxo80 200 DR 200% Super User Jean Marc Lombrez xoxoxoxo Jean-Luc Richard xoxoxoxoox254 200 DR 200 HR Super User Didier Langree xoxooxox Hans Peter Blokkum xoxoxoxoxo ------------------------Responsibility Table ResultsSelect Responsibility_Key, Responsibility_Name from responsibilitiesWhere Responsibility_Name like 'DR 200% Super User'[code]Responsibility_key------------Responsibility_NameDR_200_BOM_SUPER_USER DR 200 BOM Super UserDR_200_ENG_SUPER_USER DR 200 ENG Super UserDR_200_IMC_SUPER_USER DR 200 CON Customers Online Super UserDR_200_AP_SUPER_USER DR 200 AP Super UserThank you again vijaysionly :) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2009-07-06 : 12:50:41
|
How do you propose that you merge data with nothing in common?Like this?Table1id Value1 Apples2 Bananas3 CherriesTable2id Value1 Aretha2 Benjamin3 CeliaSo the result is?id1 Value1 id2 Value21 Apples 1 Aretha1 Apples 2 Benjamin1 Apples 3 Celia2 Bananas 1 Aretha2 Bananas 2 Benjamin2 Bananas 3 Celia3 Cherries 1 Aretha3 Cherries 2 Benjamin3 Cherries 3 Celia????????????????????????????????????????????????????????????? Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
 |
|
|
|
|
|
|
|