macromedia.coldfusion.database_access
[Top] [All Lists]

Re: Data type correct for some records, not for others

Subject: Re: Data type correct for some records, not for others
From: "-==cfSearching==-" <webforumsuser@xxxxxxxxxxxxxx>
Date: Wed, 26 Mar 2008 22:52:21 +0000 (UTC)
Newsgroups: macromedia.coldfusion.database_access

semi star gazer  wrote:
 > I have attached the error and the query, but my big question is, 
 > why do some records work and others do not? 

 There are a number of potential problems with those queries.

 1) Does the "practiceTypeID" column always have a value? Empty or null values 
would likely cause a syntax error in the second query.

 2) A column named "id" exists in both the mentors and practiceType table.  
Because you are using [i]SELECT mentors.*, [/i] (ie select all columns),  the 
query results contain two columns with the same name: "id".  That may is cause 
issues.  

 Use a column list instead, and eliminate any duplicate column names by using 
aliases.  http://www.w3schools.com/sql/sql_alias.asp let you assign a different 
name to an object within a query. 

 SELECT 

 mentors.id,  
 practiceType.id AS PracticeTypeID,  <!--- use an alias to rename the column 
"PracticeTypeID" --->
 ... other columns ...

 FROM  mentors,
            internOps_new,
            practiceType,
            practiceArea
 WHERE
  .... other conditions ...

 3) Your query appears to be missing some join conditions.  There are four (4) 
tables in the FROM clause but only three (3) conditions in your WHERE clause.  
So the query may return too many records.  How are the tables related?

 > getPracticeID

 4)  Since you are already retrieving the "practiceTypeID" in the first query, 
what is purpose the "getPracticeID" query? 



<Prev in Thread] Current Thread [Next in Thread>