I need a mysql query to update data if exists, else insert data without unique id.
Actually i have a table like this
id company_ID Employee_ID Name Relationship Dob Age Gender
1 EMPL 00001 Choodamani Spouse 11-Aug-66 49 Female
2 EMPL 00001 Komala Mother 30-Oct-39 76 Female
3 EMPL 00001 Varshini Daughter 29-Apr-04 11 Female
4 EMPL 00001 Vasudevan Employee 15-Jul-62 53 Male
5 EMPL 00002 Siddharth Son 1-Jun-00 15 Male
6 EMPL 00002 Poongavanam Mother 21-Oct-39 76 Female
7 EMPL 00002 Aruna Spouse 16-Sep-68 47 Female
8 EMPL 00002 Abirami Daughter 7-May-97 18 Female
9 EMPL 00002 Murali Employee 7-Oct-67 48 Male
if have insert a data like this,
id company_ID Employee_ID Name Relationship Dob Age Gender
1 EMPL 00001 Choodamani Spouse 11-Aug-70 45 Female
2 EMPL 00001 Nirmal Son 30-Oct-39 76 Female
In above that i have update first employee Dob and Age,
In second id 2 you can see am insert new data for same employee
Here what i need is , update a data if exist else insert as new data without unique, I need a query for this
In this table i did'nt have any unique field, id field alone has primary key and auto increment
presently am using this query to insert
INSERT INTO employee (company_id, employee_id, name, relationship, dob, age, gender) VALUES ('$company_id','$employee_id', '$name', '$relationship', '$dob', '$age', '$gender')