Hi,

I have two fields...both are not unique, but both can't be the same.

So two fields:

user | fruit |
joe11 apple
angel bananna
bobby apple
jeff orange
julie orange
angel apple
angel orange
----------
So lets say the above was my table, notice how both fields are not unique. You notice Angel appears 3 times and has a different fruit for each one.

So now I have this HTML form where you can select the user's name in a pulldown box and the type of fruit also in a pulldown box. So lets say if the end user selects Angel in the user's pulldown, and Apple for the fruit pulldown. The end user then clicks submit form and now I need a way to not allow this duplicate, since the combo Angel and Apple already exists.

Is there some sort of INSERT INTO statement where it inserts 2 values if and only those 2 values dont already exist.???

Thanks,
Bobby

make the two fields unique in combination. it is probably possible in MySQL but this is how to do it in PostgreSQL. If the syntax is different in MySQL you'll have to check the docs

ALTER TABLE navigation_nodes
  ADD CONSTRAINT unq_controller_action_names UNIQUE(controller_name, action_name);
--COMMENT ON CONSTRAINT unq_controller_action_names ON 
--navigation_nodes IS 'make sure same node is not duplicated';

In MySql create a key that consist of both fields. When inserting a duplicate the insert will fail.