Ask a Question related to Coldfusion Database Access, Design and Development.
-
Bugsville #1
table alias mssql problem
I get this error:
The column prefix 'F' does not match with a table name or alias name used in
the query.
with the query below
Any ideas as to the problem?
TIA!
- b
<cfquery name="getFolders" datasource="#request.datasource#">
select F.*
from Folders F, folderPerm P
INNER JOIN Folders S ON S.foldermaster = F.FolderID
where F.folderid = P.FolderID
and P.staffID = #arguments.memberID#
and (F.folderMaster = 0)
order by #arguments.sortby#
</cfquery>
Bugsville Guest
-
Copying complete table from one MSSQL database toanother
I will soon have to move a complete table from one database to another (including the table structure and data in the table). Is there an easy way... -
#40064 [NEW]: Wrong fieldnames in result (including table alias names)
From: christoph at ziegenberg dot de Operating system: Windows XP SP2 PHP version: 5.2.0 PHP Bug Type: PDO related Bug... -
#33809 [Com]: pg_fetch_result: table alias produces invalid column result error
ID: 33809 Comment by: alan8 at maths dot topology dot org Reported By: torpedo51 at yahoo dot com Status: No... -
Update MSSQL table with Uploaded MS Access DB
I could use a little advice in this task. I have (potentially) dozens of users that will want to update their data on our server (MSSQL) by simply... -
importing a text file into a MSSQL table
I am trying to import a tab delimited text file into a MSSQL table and am not having much luck. the challenge is that the text file has 245 fields... -
philh #2
Re: table alias mssql problem
Hi Bugs,
Does this query work in Query Analyzer with hard-coded information?
philh Guest
-
Bugsville #3
Re: table alias mssql problem
It does not, I get the same error.
It all looks proper so I am at my wits end as to what the problem could be.
Bugsville Guest
-
LL@Work #4
Re: table alias mssql problem
Take a closer look at your syntax.
"INNER JOIN Folders S" should be "INNER JOIN Folders F"
LL@Work Guest
-
Bugsville #5
Re: table alias mssql problem
Well, that didn't seem right to me, but I tried it anyway and got:
"The correlation name 'F' is specified multiple times in a FROM clause."
any other ideas? It all looks correct to me...
Bugsville Guest
-
paross1 #6
Re: table alias mssql problem
Well, you have two tables, Folders F and folderPerm P, in your FROM clause,
then an INNER JOIN with a third. All three should be joined with INNER JOIN
statements. Something like the example below:
select F.*
from Folders F
INNER JOIN folderPerm P ON F.folderid = P.FolderID
INNER JOIN Folders S ON S.foldermaster = F.FolderID
where P.staffID = #arguments.memberID#
and (F.folderMaster = 0)
order by #arguments.sortby#
Phil
paross1 Guest
-
Bugsville #7
Re: table alias mssql problem
That resolved the error, but It is not delivering the results I am expecting.
Maybe this will help:
What I have is a folders table and a folderPerm (folderpermissions) table
I want to pull the folders that the specific user has permission set to view.
Now in the folders table, there is a masterfolder field, which is the ID of
the folder that the specific record is a SUBfolder of.
So the query needs to deliver all folders and subfolders that the user has
permission to view and some folders do NOT have subfolders.
does that make sense?
And thanks to all who have helped so far!
Bugsville Guest
-
paross1 #8
Re: table alias mssql problem
Are you missing the ones that have no subfolders? Try a LEFT (OUTER) join.
select F.*
from Folders F
INNER JOIN folderPerm P ON F.folderid = P.FolderID
LEFT JOIN Folders S ON S.foldermaster = F.FolderID
where P.staffID = #arguments.memberID#
and (F.folderMaster = 0)
order by #arguments.sortby#
Phil
paross1 Guest
-
paross1 #9
Re: table alias mssql problem
.....or is this more like what you are trying to do?
SELECT F.*
FROM Folders F
INNER JOIN folderPerm P ON F.folderid = P.FolderID
WHERE P.staffID = #arguments.memberID#
AND (F.folderMaster = 0)
UNION
SELECT S.*
FROM Folders S
INNER JOIN Folders F ON S.foldermaster = F.FolderID
INNER JOIN folderPerm P ON F.folderid = P.FolderID
WHERE P.staffID = #arguments.memberID#
AND (F.folderMaster = 0)
ORDER BY #arguments.sortby#
Phil
paross1 Guest
-
Bugsville #10
Re: table alias mssql problem
Originally posted by: paross1
Are you missing the ones that have no subfolders? Try a LEFT (OUTER) join.
Exactly what I needed! thanks!
Bugsville Guest



Reply With Quote

