PDA

View Full Version : SQL brain fart



lunatic
October 4th, 2004, 06:28 PM
I feel like I am having a total brain fart. I am trying to use a select * where statement to get all the records from my database that match a given setup and using a URL variable:



SELECT *
FROM dbo.TerraLogMain
WHERE Volume = '#URL.VolumeID#'


Now I know for a fact that there are multiple records for Volume = Maps2 for example but I am only getting one record returned.

It also looks like the URL variable is getting passed okay:

http://localhost/GISTerraLog/VolumeDetail.cfm?VolumeID=Maps2

So any clues as to what I am missing?

Thanks for any help,
:hr:

amitgeorge
October 5th, 2004, 01:51 AM
try passing the sql to a cftable.... or

try to print the SQL statement

SELECT *
FROM dbo.TerraLogMain
WHERE Volume = '#URL.VolumeID#'

so it comes out like

SELECT *
FROM dbo.TerraLogMain
WHERE Volume = 'Maps2'

If that is ok then try to execute this staement from Query Analyser.

you should find out your problem.

teiz77
October 5th, 2004, 08:15 AM
try passing the sql to a cftable.... or

try to print the SQL statement

SELECT *
FROM dbo.TerraLogMain
WHERE Volume = '#URL.VolumeID#'

so it comes out like

SELECT *
FROM dbo.TerraLogMain
WHERE Volume = 'Maps2'

If that is ok then try to execute this staement from Query Analyser.

you should find out your problem.
how do you process the results? In PHP you must do a do while loop to get the results displayed. I don't know the cf drill...

lunatic
October 5th, 2004, 11:40 AM
I tried doing a direct command



SELECT *
FROM dbo.TerraLogMain
WHERE Volume = 'Maps6'


but I still only get one record. I've never used cftable - I'm just having them display in an html table. I don't have access to Query Analyzer until next week when our SQL guy comes back from a meeting in Denver (he's got the passwords into sql server. I'm really gonna have to bug him to add me as an admin onto that system).

Anything else I could try?

thanks for your help

:hr:

p.s. PHP I think is different in this case than SQL or CF - no loops necessary for this type of process. SELECT * means select all records FROM the table specified WHERE the condition exists. But thanks for trying! :)

amitgeorge
October 6th, 2004, 01:39 AM
if you have access to query analyser then you can run the query to see the results or you can download a web based database admin.

cftable prints out data from a sql query in html table format

lunatic
October 6th, 2004, 11:56 AM
Thanks for the info - I'm gonna check out cftable when I get the chance just to learn about it.

I actually did solve my problem and like I thought it was a big brain fart. I used a simple <cfoutput> for my query when I should have used <cfoutput query="myquery">. Once I changed it it worked just fine.

Go figure. :sure:

Thanks for your help everyone!! :D