Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:18:58+00:00 2026-06-06T00:18:58+00:00

I have a table that contains all the data about users . Users can

  • 0

I have a table that contains all the data about users. Users can however have multiple email adresses so i need to store them in a seperate table.

I want to run searches based on an email adresses that return all the information about the user. (i also want to be able to search the user table by username which is stored in the user table)
What is the best way to store the email adresses in my database??
I dont think introducing a redundant email adress field in the user table is a good idea, but possibly it is??

for now i have a user table linked to the email table with 1:M relationship.
(so email adress contains user_id as part of its primary key)

after i store the email adresses what is the best way to get all the information with mySql query (so please include mySQL in your answer)

I know about JOIN opperation but i dont know how to use it with this search.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:19:00+00:00Added an answer on June 6, 2026 at 12:19 am

    You can store your data like that, assuming all emails are unique (I added UNIQUE KEY there)

    CREATE TABLE `users` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(50) NOT NULL,
      PRIMARY KEY (`id`)
    ) DEFAULT CHARSET=utf8;
    
    CREATE TABLE `emails` (
      `email` varchar(50) NOT NULL,
      `user_id` int(10) unsigned NOT NULL,
      PRIMARY KEY (`email`),
      KEY `user_id` (`user_id`)
    ) DEFAULT CHARSET=utf8;
    

    You can retrieve data for specific email like that:

    SELECT users.*, emails.email
    FROM users
    JOIN emails ON users.id = emails.user_id
    WHERE emails.email = 'some_mail@example.com'
    

    You can also select all emails user have like so:

    SELECT users.*, GROUP_CONCAT(emails.email) 
    FROM users
    LEFT JOIN emails ON users.id = emails.user_id
    WHERE users.id = 1234
    GROUP BY users.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains temporary data which uses a column to store
I have a table of data that contains about 260 rows. Each of these
I have a table that contains all the employees in a company (hr_employees). In
I have table that contains more than 12 millions of rows. I need to
I have a table that contains members names and a field with multiple ID
I need to store a large table (several millions or rows) that contains a
I have a table that contains several thousand rows, having a Varchar column that
I have a table that contains rows with different class names. Some of these
I have a table that contains events, to list these events I loop through
I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.