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 6551875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:23:29+00:00 2026-05-25T12:23:29+00:00

I have two mysql table Table 1 id email other fields Table 2 id

  • 0

I have two mysql table

Table 1

id email  other fields

Table 2

id email other fields 

where id for table1 is auto increment mysql column. and in table 2 id is only primary key not NULL .

some how the id for table 2 had gone wrong.
Now both tables are having some records and I want to make id in table 2 same as table 1.

let’s take an example

Table 1 have

1 a@a.com
2 b@b.com 

Table 2 have

1 b@b.com
2 a@a.com 

if I fire query

update 
  table2 
set 
  id=(select id from table 1 where email="a@a.com") 
where 
  email = "a@a.com"

I will get error because table 2 is already having id value of 2.
now how can I solve this problem ?

I want id of table2 same as table1 based on email.

  • 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-25T12:23:30+00:00Added an answer on May 25, 2026 at 12:23 pm

    How about this :

    update table2 set email=(
    case
    when email='b@b.com' Then 'a@a.com'
    when email ='a@a.com' Then 'b@b.com'
    end)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables named MEMBER - columns id(primary key), name, email & TOPICS
I have two mysql tables: /* Table users */ CREATE TABLE IF NOT EXISTS
using php and mysql I have two tables, a users table and a profiles
i work with php/Mysql i have table with two cols (date , cash) with
I am using MYSQL and PHP. I have a table called item. Two of
Say I have an MSSQL table with two columns: an int ID column that's
I have two servlets: LoginServlet and MailServlet. LoginServlet queries a mysql table using jdbc
I have one MySQL table, users , with the following columns: user_id (PK) email
I have two MySQL databases with identical table structure, each populated with several thousand
I have a MySQL database with these two tables: Tutor(tutorId, initials, lastName, email, phone,

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.