Hi,
I have the following Insert query: (all this data is coming from a form)
<cfquery name="insertdata" datasource="MainDB">
INSERT INTO newUsersTable (NewUserTodayDate, UserID, UserFirstName, UserLastName, UserAddress , UserPhoneNumber, UserComments) VALUES
('#DATEFORMAT(Now(), "mm/dd/yyyy")#', '#form.UserID#', '#form.UserFirstName#', '#form.UserLastName#', '#form.UserAddress#', '#form.UserPhoneNumber#', '#form.serComments#')
</cfquery>
Question: How do I change this query to check if a record already exist for the UserID entered, then append to existing data and if UserID does not exist insert data in the table. also if the UserID already exists and i'm appending data, i want some kind of new line character so that the appending data is in a new line.
For ex: UserComments
Joe bought a coverage for $100 on 10/12/12.
Joe is changing his coverage to $500 on 12/12/12.
Not together: Joe bought a coverage for $100 on 10/12/12. Joe is changing his coverage to $500 on 12/12/12.
UserID is not my primary key and not autonumber. it is already existing IDCard numbers of the users.
ANy help is appreciated. Thanks in advance.
I have the following Insert query: (all this data is coming from a form)
<cfquery name="insertdata" datasource="MainDB">
INSERT INTO newUsersTable (NewUserTodayDate, UserID, UserFirstName, UserLastName, UserAddress , UserPhoneNumber, UserComments) VALUES
('#DATEFORMAT(Now(), "mm/dd/yyyy")#', '#form.UserID#', '#form.UserFirstName#', '#form.UserLastName#', '#form.UserAddress#', '#form.UserPhoneNumber#', '#form.serComments#')
</cfquery>
Question: How do I change this query to check if a record already exist for the UserID entered, then append to existing data and if UserID does not exist insert data in the table. also if the UserID already exists and i'm appending data, i want some kind of new line character so that the appending data is in a new line.
For ex: UserComments
Joe bought a coverage for $100 on 10/12/12.
Joe is changing his coverage to $500 on 12/12/12.
Not together: Joe bought a coverage for $100 on 10/12/12. Joe is changing his coverage to $500 on 12/12/12.
UserID is not my primary key and not autonumber. it is already existing IDCard numbers of the users.
ANy help is appreciated. Thanks in advance.