jairathnem Posted February 17, 2014 Share Posted February 17, 2014 Hello, My scenario is I need to have a unique value in a column based on value from another column. for ex : I have item_ID and product column For every item_ID there should only be unique values in the product column. item_ID Product 1 1 1 2 1 4 2 1 but if I insert 1 in item_ID and 1 in product now, it should throw an error. I have no idea how to implement this. Any help appreciated. Link to comment https://forums.phpfreaks.com/topic/286255-unique-value-based-on-another-column/ Share on other sites More sharing options...
Barand Posted February 17, 2014 Share Posted February 17, 2014 Specify a unique key on (Item_id, product) Link to comment https://forums.phpfreaks.com/topic/286255-unique-value-based-on-another-column/#findComment-1469222 Share on other sites More sharing options...
jairathnem Posted February 18, 2014 Author Share Posted February 18, 2014 Thanks Barand. Unique index does the job Link to comment https://forums.phpfreaks.com/topic/286255-unique-value-based-on-another-column/#findComment-1469354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.