Mark

FROM    tree, 
        species LEFT OUTER JOIN region_tree     ON 
        tree.treeUUID = region_tree.treeUUID

Your joining species and region_tree
is that right?

you can only join tables in your ON clause that you define in your JOIN clause

Steve

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Mark
Stanton
Sent: Thursday, February 12, 2004 7:42 PM
To: CFAussie Mailing List
Subject: [cfaussie] MS SQL problem


Hey All

Been beating my head against this one for a while now..... I've got two queries that 
work and a third (which is the one I am really after) that doesn't.


--- Query 1 - get trees & their species - works fine ---
SELECT  tree.treeUUID, 
                tree.treeName,
                species.speciesDesc
                                        
FROM            tree, 
                species

WHERE           species.speciesUUID = tree.speciesUUID



--- Query 2 - get trees & their regions (if defined) - works fine ---
SELECT  tree.treeUUID, 
                tree.treeName,
                region_tree.regionUUID
                                        
FROM            tree

LEFT OUTER JOIN region_tree
ON              tree.treeUUID = region_tree.treeUUID

GROUP BY        tree.treeUUID, 
                tree.treeName, 
                region_tree.regionUUID



--- Query 3 - combination of the above - broken ---
SELECT  tree.treeUUID, 
                tree.treeName,
                region_tree.regionUUID,
                species.speciesDesc
                                        
FROM            tree, 
                species



LEFT OUTER JOIN region_tree
ON              tree.treeUUID = region_tree.treeUUID

WHERE           species.speciesUUID = tree.speciesUUID

GROUP BY        tree.treeUUID, 
                tree.treeName,
                region_tree.regionUUID,
                species.speciesDesc


The error I get is:
Server: Msg 107, Level 16, State 3, Line 1
The column prefix 'tree' does not match with a table name or alias name used in the 
query.

Any ideas?


Cheers

Mark


------------------
Mark Stanton 
Technical Director 
Gruden Pty Ltd 
Tel: 9956 6388
Mob: 0410 458 201 
Fax: 9956 8433 
http://www.gruden.com


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to