How to prevent duplicate entries but allow duplicates in one column MYSQL?

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) |

fakeemail@gmail.com | 12534134134135341
fakeemail@gmail.com | 44341341341341343
fakeemail@gmail.com | 65656542242434134
supercool@gmail.com | 12534134134135341
totallyreal@gma.com | 44341341341341343
lolzzz123@gmail.com | 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:

fakeemail@gmail.com | 12534134134135341
fakeemail@gmail.com | 12534134134135341
fakeemail@gmail.com | 12534134134135341

^^ How can i prevent the above while still allowing both columns to have duplicates?

>Solution :

SELECT 
email,
restaurant-id
FROM 
your_table
GROUP BY 
email,
restaurant-id

Leave a Reply