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

  • Home
  • SEARCH
  • 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 878791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:49:13+00:00 2026-05-15T11:49:13+00:00

Here is my USER table CREATE TABLE IF NOT EXISTS `users` ( `id` int(11)

  • 0

Here is my USER table

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(100) NOT NULL,
  `expiry` varchar(6) NOT NULL,
  `contact_id` int(11) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(100) NOT NULL,
  `level` int(3) NOT NULL,
  `active` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`,`email`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

And here is my contact_info table

CREATE TABLE IF NOT EXISTS `contact_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email_address` varchar(255) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `license_number` varchar(255) NOT NULL,
  `phone` varchar(30) NOT NULL,
  `fax` varchar(30) NOT NULL,
  `mobile` varchar(30) NOT NULL,
  `category` varchar(100) NOT NULL,
  `country` varchar(20) NOT NULL,
  `state` varchar(20) NOT NULL,
  `city` varchar(100) NOT NULL,
  `postcode` varchar(50) NOT NULL,
  PRIMARY KEY (`id`,`email_address`),
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

The system uses username to login users. I want to modify it in such a way that it uses email for login. But there is no email_address in users table.

I have added foreign key – email in user table(which is email_address in contact_info).

How should I query database?

  • 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-05-15T11:49:14+00:00Added an answer on May 15, 2026 at 11:49 am

    No, no, no, no no. Seriously, no. Don’t make me come over there 🙂

    You’re breaking third normal form by storing the email address twice.

    The relationship need only be a short one, that of id. Assuming you’re not guaranteeing the IDs will be identical in the two tables (i.e., my users.id isn’t necessarily equal to my contact_info.id), just add a ci_id to the users table to act as a foreign key to the contact_info table.

    Then the query to get a user’s username and email will be something like:

    select u.username, ci.email
    from users u, contact_info ci
    where u.username = 'paxdiablo'
    and u.ci_id = ci.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is usually called multi-tenancy. Here is a presentation or… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer import time now = time.time() ... later = time.time() difference… May 16, 2026 at 3:58 pm
  • Editorial Team
    Editorial Team added an answer Use std::ofstream This is because we have to explicitly specify… May 16, 2026 at 3:58 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Consider the following database schema: create table UserGroup ( id int not null auto_increment,
Here's my table schema [dbo].[Action_History]( [ActionID] [int] IDENTITY(1,1) NOT NULL, [objectID] [int] NOT NULL,
I have tried many things, but I'm still not getting this to work. Here's
I am having trouble with my queries not returning any results. There are no
I found out how to find if the database exists with this code: if(mysql_select_db('db-name'))
sorry about the title, I'm not sure how to even describe this, which makes
Using SQL Server 2008, I have a requirement that email addresses in my user
I have small problem when trying to create many-to-many link in doctrine. I have
Please see the code here: http://pastie.org/1092106 When I call the method createPost on Blog,
I have a table where it has two datetimes, one of them is a

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.