View Full Version : ColdFusion Query Result

11-08-2004, 10:21 PM
How do I go about checking to see if a query result returned a blank field, when selecting more than one field (which means the recordcount wont work). Here's my query.

<cfquery name="GetArtist" datasource="MySQL_Users">
SELECT ArtistName,
FROM Artist_Info
WHERE UserName = "#Session.UserName#"
AND Password = "#Session.Password#"

Now for example, lets say artist name is there, and song 1 is there. How can I find out if song2 and song3 are empty. I need to do this for a few reasons, but the main one now is for a comparison. If the artist query returns blank, cfoutput is "Register Artist" while if it returns a name, cfoutput is "Edit Artist".

11-09-2004, 05:03 PM
You just need to do some simple checking using <CFif />

If you're using <CFoutput /> with the query attribute, then it might be something like this:

<CFoutput query="GetArtists">
<CFif song1 is "">... do something ...</CFif>

And then if you want to check outside a loop:

<CFoutput query="GetArtists">

<CFif GetArtists.song1 is "">... do something ...</CFif>

But based on the simple snippet you've shown alone, I feel like I could assume you've got such basics covered, so I wonder if you were unclear or I didn't understand something quite right.