"Sweeney, Darren L" wrote:
>
> Hi
>
> I am running an app where I am pulling data from a table (TableA), if it is
> there, into a form, and then the user completes the form and submits half of
> the data back to TableA, and the other half to another (TableB) ... simple
> enough.
>
> The first half of the data though (TableA), if it is not there, will leave
> the form fields blank for the user to also complete.
>
> What I need to do is then update TableA with the new data that the user has
> filled in. When I submit though, if the data was already there it will
> create a duplicate record, which I cannot allow.
>
> So, my way of thinking is to set one of the columns in TableA to be the
> primary key and then if the data is not there it will be input OK, if it is
> there though, it will cause the ERROR 1062 message and not add to the table.
>
> This does not feel like the best way to do this but I cannot think of
> another way ... any ideas?
>
> Thanks
>
> Darren
>
If I understand the problem correctly, what you are looking for is
REPLACE INTO
--
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)