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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:58:47+00:00 2026-05-25T20:58:47+00:00

I have a column contactId on one table which is a foreign key, connected

  • 0

I have a column contactId on one table which is a foreign key, connected to the id of contacts table. I.e, every row in my 2nd table can be connected to a contact.

However, some records don’t have to be connected to any contacts. In such cases, the contact Id would be 0. When I try to insert such a record, I get this error:

Error Number: 1452 Cannot add or update a child row: a foreign key constraint fails 

What should I do?

  • 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-25T20:58:48+00:00Added an answer on May 25, 2026 at 8:58 pm

    If the column contactId that has the FK to the other table is nullable (and it can be) you should be able to just set those that don’t have any contacts to NULL. A foreign key basically means that if the column has a non-NULL value, then that value has to exist in the primary key of the table referenced by the foreign key constraint. Otherwise, just set it to NULL.

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

Sidebar

Related Questions

I have a table I store contacts and their phones. Contact : ContactId (int,
I have to map two simple table with a foreign key relationship. One of
I need a select from table which does not have column that tells when
I have a view that displays a table: rows represent days - one row
I have a contact, and contact has_many :phones. The phones table has a column
I have a table, with one column <table> <tr> <td width=30 class=top-nav><a href=#>Home</a></td> <td
I have two tables: <class name=Content table=language_content lazy=false> <composite-id> <key-property name=contentID column=contentID/> <key-property name=languageID
I have column named summary (tinytext, utf8_turkish_ci). I know it can store 255 byte
I have a column which is of type nvarchar(max). How do I find the
I have a table that lists people and all their contact info. I want

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.