Hi I have two tables Experiment and Sample. I want to create a trigger such that if there is a entry in the 'Sample' table it should check if 'Experiment_name' and 'Sample_name' is same as the previous entry and if both matches then it should update that row and if not then it should enter a new row.
For example
EXPERIMENT TABLE
Experiment_id(auto_incremented) Exp_name
1 ABC
SAMPLE TABLE
Sample_id Experiment_id Experiment_name sample_name Sample_result
1 1 ABC abc 100
2 1 ABC xyz 100
3 1 ABC hjk 300
**New Entry - Experiment name - ABC and sample_name - xyz then Sample_result - 200 **
SAMPLE TABLE
Sample_id Experiment_id Experiment_name sample_name Sample_result
1 1 ABC abc 100
**2 1 ABC xyz 200**
3 1 ABC hjk 300
If Experiment name - ABC and sample_name - wer did not exist then Sample_result - 200 should be inserted as a new row.
SAMPLE TABLE
Sample_id Experiment_id Experiment_name sample_name Sample_result
1 1 ABC abc 100
2 1 ABC xyz 100
3 1 ABC hjk 300
**4 1 ABC wer 200**
I could simply do this using update but I am using MySQL workbench and I will be impoting data from CSV using the import wizard and that is why I want it to be automated.
I am using mysql 5.7.22. Please someone help me, thanks!!