Sunday, December 29, 2013

if primary id is exist update record otherwise insert record in mysql ( ON DUPLICATE KEY)

Same Query we can do the insert and update process in mysql

For Example:

Consider following query  if key id is  '1' existing table  it will perform update query like second query. otherwise it will insert as new record.

INSERT INTO product (id,name,price) VALUES (1,'jeeva','$100')
  ON DUPLICATE KEY UPDATE name='jeeva',price='$100';

UPDATE table SET name='jeeva',price='$100' WHERE id=1;

Bind Some Event to Element and trigger that function when click the element

Scenario: Suppose if we used same click event function in various web pages. if you want do some logic some page button for that need to re...