Mysql function: Insert if not exist or updated

I am having a small problem- How would I write a function in mysql to insert a record if it doesn't exist or if its a case where it exists then say for example the record is updated a fresh copy of the default record should be reinserted leaving the updated record in the table. Let me give a small scenario, please read carefully before bashing me, I'm trying to explain as best as I can:

table name= Computer.
Columns(2) = comp_id(Auto-increment), comp_name. 

Default Data I'd want to be in the table=

comp_id= 1, comp_name='Dell'

Now if I should Update this information to:


The function should automatically add the previous record which was:


I thought of using update if not exist but I was reading a blog and they stated Mysql does not support update if not exist. If you could provide any suggestions I'd really appreciate, Thanks.



Need Your Help

value is not fetched using jquery for text box

jquery html input inputbox

i have a text box and i try to get value like this

Check if a link already exists on a page


I'm trying to solve for two scenarios:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.