Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"If not exists"

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
What is the code I can include in my CF form to check a SQL table to see whether data exists for a selected customer? I am attempting to duplicate and web-enable an old pre-existing system that does this.

The only syntax I can think of is to query the table and see if the rows are not null.

Does anyone have a better method?
 
Hey Programmher,

I think the simplest method is what you mentioned.
Query for the data and check if there is something there like this:

<CFQUERY name=&quot;Check&quot; datasource=&quot;BigOldDatabase&quot;>
Select *
From tblcustomer
Where Customername = &quot;FirstCustomer&quot;
</CFQUERY>

<CFIF #Check.recordcount# is 0> Customer Not in Database
<CFELSE> Customer is in database #Check.recordcount# times
</CFIF>

I took some liberties with the table and field names but you get the idea.

Have FUN!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top