unique value based on another column value?

Jeyachandran Rathnam

Issue 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.

Wilmer

What you need is a unique index for both columns

alter table yourtable add unique index(item_ID, Product);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Pandas/Python: Set value of one column based on value in another column

From Dev

extracting value based on another column

From Dev

pig to add column based on value in another column

From Dev

How to get max value of a column based on value of another column?

From Dev

Filling a column with NA, based on the value in an another column

From Dev

How to assign a default value in a column based on another column's value?

From Dev

selecting a column based on a minimum value of another column

From Dev

Unique Constraint (Coupled with Another Column of a Certain Value)

From Dev

SQL sum one value for each unique value from another column

From Dev

Set value of column based on another column in Postgres?

From Dev

Copy value from one column based on the value of another column

From Dev

Updating one column based on the value of another column

From Dev

MySQL: Search based on a column, each unique value in another column and max time

From Dev

updating column value based on another column value

From Dev

Pandas/Python: Set value of one column based on value in another column

From Dev

Highlight a column value based off another column value in pandas

From Dev

Filtering column value based on unique value, but not repeated for different value of the same column on the same unique value

From Dev

Changing Value of adjacent column based on value of of another column

From Dev

Return Value in a column based on value in a subset in another column

From Dev

SQL Query to obtain the maximum value for each unique value in another column

From Dev

How to assign a default value in a column based on another column's value?

From Dev

mysql - Select unique column based on max value of another column in a different table

From Dev

Selecting 1 record based on last unique value that is on another column

From Dev

Remove Duplicates by Unique Value in another Column

From Dev

Python - Access column based on another column value

From Dev

Mandatory column based on the value of another column

From Dev

Populating a column based on value of another column (SQL)

From Dev

pandas - change value in column based on another column

From Dev

Select latest value of another column based on a comparison between unique keys

Related Related

  1. 1

    Pandas/Python: Set value of one column based on value in another column

  2. 2

    extracting value based on another column

  3. 3

    pig to add column based on value in another column

  4. 4

    How to get max value of a column based on value of another column?

  5. 5

    Filling a column with NA, based on the value in an another column

  6. 6

    How to assign a default value in a column based on another column's value?

  7. 7

    selecting a column based on a minimum value of another column

  8. 8

    Unique Constraint (Coupled with Another Column of a Certain Value)

  9. 9

    SQL sum one value for each unique value from another column

  10. 10

    Set value of column based on another column in Postgres?

  11. 11

    Copy value from one column based on the value of another column

  12. 12

    Updating one column based on the value of another column

  13. 13

    MySQL: Search based on a column, each unique value in another column and max time

  14. 14

    updating column value based on another column value

  15. 15

    Pandas/Python: Set value of one column based on value in another column

  16. 16

    Highlight a column value based off another column value in pandas

  17. 17

    Filtering column value based on unique value, but not repeated for different value of the same column on the same unique value

  18. 18

    Changing Value of adjacent column based on value of of another column

  19. 19

    Return Value in a column based on value in a subset in another column

  20. 20

    SQL Query to obtain the maximum value for each unique value in another column

  21. 21

    How to assign a default value in a column based on another column's value?

  22. 22

    mysql - Select unique column based on max value of another column in a different table

  23. 23

    Selecting 1 record based on last unique value that is on another column

  24. 24

    Remove Duplicates by Unique Value in another Column

  25. 25

    Python - Access column based on another column value

  26. 26

    Mandatory column based on the value of another column

  27. 27

    Populating a column based on value of another column (SQL)

  28. 28

    pandas - change value in column based on another column

  29. 29

    Select latest value of another column based on a comparison between unique keys

HotTag

Archive