0

I can't get my head around the MySQL I need; I want insert a row only if the variety is unique against plant_id in the same table. My example is:

id  plant_id  variety
1   1         cara
2   1         rocket
3   2         money maker
4   2         crimson crush

So....

plant_id = 1; variety = cara - I don't want this to be added as there is already as it is duplicate on both fields.

plant_id = 2; variety = cara - I do want this to be add as there isn't record with the plant_id = 2 and a variety of cara

I tried to make a composite key but this failed because neither of the fields will be unique in themselves.

I'm not a SQL guru so be kind to me, but quiz me if this make no sense! :)

0 Answers0