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 |
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-02-14 : 13:10:10
|
| I know I’m syntactically fubar on this, but you should be able to see what I’m trying to do. What approach do I need to take with this?:SELECT * FROM DOUGLASMNI.dbo.MNI t1WHERE FNAME AND MNAME AND LNAME IN (SELECT FNAME AND MNAME AND LNAME FROM MNI.dbo.mni t2 WHERE t2.FNAME=t1.FNAME AND T2.MNAME=T1.MNAME AND T2.LNAME=T1.LNAME) |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-02-14 : 13:22:17
|
| at'll do. thanks again. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-14 : 13:44:42
|
might result in varied record count from original query if relationship between tables is one to many (ie multiple records existing in MNI.dbo.mni with same FNAME ,MNAME ,LNAME combinationsso I prefer EXISTS checkSELECT * FROM DOUGLASMNI.dbo.MNI t1WHERE EXISTS(SELECT 1 FROM MNI.dbo.mni t2 WHERE t2.FNAME=t1.FNAME AND T2.MNAME=T1.MNAME AND T2.LNAME=T1.LNAME) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-14 : 13:50:48
|
quote: Originally posted by X002548 How is that going to allow a compare?If the tables have the same number of Columns SELECT 'DOUGLASMNI.dbo.MNI' AS SOURCE, * FROM DOUGLASMNI.dbo.MNIUNION ALL SELECT 'MNI.dbo.mni' AS SOURCE,* FROM MNI.dbo.mniORDER BY.... Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/
Unless I miss something I dont think OP specified anything re. comparing of values. I thought the original query posted was trying to use MNI.dbo.mni as a kind of lookup to see if details which existed in MNI.dbo.mni was getting retrieved------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|