Hi,
Ive come across another problem that I'm hoping someone might be able to help me with??
Im trying to select a unique record from a users table which contains a primary key (username) and a table called userspecific which also contains a field called username which acts as a foriegn key to the user table.
My SQL query is as follows:
<!--- Make sure the right user is being referenced via my application.cfm--->
<CFOUTPUT>
#Client.UserName#
</cfoutput>
<!--- If the variable UserName (person logged in) is not defined then re-direct to Login.cfm else carry on--->
<CFIF NOT IsDefined("Client.UserName"
>
<CFLOCATION URL = Login.cfm>
<CFELSE>
<!--- Query my database to select userName from (my only) two tables "Users" and "userSpecifc" where
username logged in matches both a row in the users table and the userspecific table --->
<CFQUERY DATASOURCE = "ONLINE" NAME = "GetUser">
SELECT distinct Users.UserName, UserSpecific.UserName
FROM Users INNER JOIN USERSPECIFIC ON Users.UserName = UserSpecific.UserName
</CFQUERY>
</CFIF>
Currently, this query returns two records when only one should be received
On the same page, I am writing a query to insert the data captured via the form into a DB, and it is inserting into two rows instead of only 1?? ( i know that if my query above is not correct then the upadate will not be correct)
The update SQL is as follows:
<CFIF #GetUser.RecordCount# EQ 1>
</CFIF>
<CFIF Not IsDefined("FORM.Title"
>
Variable not passed
<CFELSE>
<CFQUERY NAME = "DataAdded" DATASOURCE = "Online" >
UPDATE UserSpecific
SET
Title = '#form.title#'
</CFQUERY>
Based on this information, I want to output details from the table, but if the query to update is not cprrect I cant extract the correct data.
Help would be greatly appreciated!!
Cheers
Sam
Ive come across another problem that I'm hoping someone might be able to help me with??
Im trying to select a unique record from a users table which contains a primary key (username) and a table called userspecific which also contains a field called username which acts as a foriegn key to the user table.
My SQL query is as follows:
<!--- Make sure the right user is being referenced via my application.cfm--->
<CFOUTPUT>
#Client.UserName#
</cfoutput>
<!--- If the variable UserName (person logged in) is not defined then re-direct to Login.cfm else carry on--->
<CFIF NOT IsDefined("Client.UserName"
<CFLOCATION URL = Login.cfm>
<CFELSE>
<!--- Query my database to select userName from (my only) two tables "Users" and "userSpecifc" where
username logged in matches both a row in the users table and the userspecific table --->
<CFQUERY DATASOURCE = "ONLINE" NAME = "GetUser">
SELECT distinct Users.UserName, UserSpecific.UserName
FROM Users INNER JOIN USERSPECIFIC ON Users.UserName = UserSpecific.UserName
</CFQUERY>
</CFIF>
Currently, this query returns two records when only one should be received
On the same page, I am writing a query to insert the data captured via the form into a DB, and it is inserting into two rows instead of only 1?? ( i know that if my query above is not correct then the upadate will not be correct)
The update SQL is as follows:
<CFIF #GetUser.RecordCount# EQ 1>
</CFIF>
<CFIF Not IsDefined("FORM.Title"
Variable not passed
<CFELSE>
<CFQUERY NAME = "DataAdded" DATASOURCE = "Online" >
UPDATE UserSpecific
SET
Title = '#form.title#'
</CFQUERY>
Based on this information, I want to output details from the table, but if the query to update is not cprrect I cant extract the correct data.
Help would be greatly appreciated!!
Cheers
Sam