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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:37:46+00:00 2026-06-02T11:37:46+00:00

this is my alter statement trying to connect two tables: ALTER TABLE my_contacts CHANGE

  • 0

this is my alter statement trying to connect two tables:

ALTER TABLE my_contacts 
  CHANGE `profession` `profession_id`  INT NOT NULL, 
  ADD CONSTRAINT professions_profession_id_fk 
  FOREIGN KEY (profession_id) REFERENCES professions (profession_id)

and I have the following error:

#1452 - Cannot add or update a child row: a foreign key constraint fails (`contacts`.<result 2 when explaining filename '#sql-1ca_73'>, CONSTRAINT `professions_profession_id_fk` FOREIGN KEY (`profession_id`) REFERENCES `professions` (`profession_id`))

can anyone guide me on what this is? I am actually learning how to write sql myself since I have used tools all this while.

  • 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-02T11:37:47+00:00Added an answer on June 2, 2026 at 11:37 am

    Your foreign key constraint is failing.

    The foreign key you are trying to create enforces every profession_id in my_contacts to be present in your professions table. Right now, this is not the case. You should lookup all records in my_contacts where the profession_id is not present in professions and fix those first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used this query to alter the table field: ALTER TABLE `recordstudent` CHANGE
I'm trying a very simple drop column statement: alter table MyTable drop column MyColumn
When I run this ALTER TABLE agency ADD COLUMN single_word varchar(100) I get Msg
Usually I run a script like this: ALTER TABLE [TABLE] ALTER COLUMN [Column] NVARCHAR(40);
I have this sql: ALTER TABLE dbo.ChannelPlayerSkins DROP CONSTRAINT FK_ChannelPlayerSkins_Channels but apparently, on some
I trying to make method to alter table. I've build data.db Created new group
I'm trying to insert values in my database This is the statement I try
I am having trouble with a ALTER TABLE command that I am trying to
Revisiting MySQL, and trying to change the structure of the table. I want to
I am getting an error when trying to create a relationship within two tables

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.