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 |
|
brucezepplin
Starting Member
15 Posts |
Posted - 2011-07-20 : 04:59:14
|
Hi, I'm having trouble sorting out a nested select statements joined together:SELECT * FROM(SELECT DISTINCT NAMEFROM NAME_DBWHERE NAME = 'HOMER') AJOIN (SELECT DISTINCT NAMEFROM NAME_DBWHERE NAME = 'HOMER') BJOIN (SELECT DISTINCT NAMEFROM NAME_DBWHERE NAME = 'HOMER') CON A.NAME = B.NAMEAND A.NAME = C.NAMEAND B.NAME = C.NAME the error statement I am getting is sql0104n: an unexpected token "(SELECT DISTINCT NAME FROM NAME_DB" was found following " ) B JOIN " expected tokens may include <space>do not worry about the field names etc etc, this is just a simplified version of what I am working on - it's the logic that doesnt appear to be working. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2011-07-20 : 05:15:01
|
I suspect you are coming from Access or other database application.Learn ANSI style joins. Try thisSELECT *FROM ( SELECT DISTINCT NAME FROM NAME_DB WHERE NAME = 'HOMER' ) AS aINNER JOIN ( SELECT DISTINCT NAME FROM NAME_DB WHERE NAME = 'HOMER' ) AS b ON b.NAME = a.NAMEINNER JOIN ( SELECT DISTINCT NAME FROM NAME_DB WHERE NAME = 'HOMER' ) AS c ON c.NAME = a.NAME N 56°04'39.26"E 12°55'05.63" |
 |
|
|
brucezepplin
Starting Member
15 Posts |
Posted - 2011-07-20 : 05:24:43
|
| that worked like a charm. thanks very much! |
 |
|
|
|
|
|