I have a MYSQL table that stores restaurant IDs to email address. Any given email address can have as many restaurant IDs added to it. for example:
| email VARCHAR(45) | restaurant-id VARCHAR(45) |
[email protected] | 12534134134135341
[email protected] | 44341341341341343
[email protected] | 65656542242434134
[email protected] | 12534134134135341
[email protected] | 44341341341341343
[email protected] | 65656542242434134
I currently have no primary key set because both columns need to be able to have duplicate entires. What I am looking to prevent is the following duplicates:
[email protected] | 12534134134135341
[email protected] | 12534134134135341
[email protected] | 12534134134135341
^^ How can i prevent the above while still allowing both columns to have duplicates?
CodePudding user response:
SELECT
email,
restaurant-id
FROM
your_table
GROUP BY
email,
restaurant-id