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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:06:19+00:00 2026-05-27T04:06:19+00:00

I have a teamnews Table: And another table called team: The values in teamnews

  • 0

I have a teamnews Table: enter image description here

And another table called team:
enter image description here

The values in teamnews table are predetermined before a user signs into the site.
Lets say when a user(teamName) signs in I want to update the teamID row where NewsID = 1
And create a relationship so that if I eventually delete the user(teamName) the teamID value in the teamNews table is reset to zero.

Is this possible?
Please bare in mind I am using phpMyAdmin, so I am not entirely familiar with advanced SQL terms.

When I try to do this I get and error: enter image description here

Here’s the error:

enter image description here

  • 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-27T04:06:20+00:00Added an answer on May 27, 2026 at 4:06 am

    You need to specify a FOREIGN KEY. You can add it in by running this command:

    ALTER TABLE teamnews
    ADD CONSTRAINT fk_teamID
      FOREIGN KEY (TeamID)
      REFERENCES team (teamID)
      ON DELETE SET NULL;
    

    This sets up a formal relationship between the tables using the foreign key. The ON DELETE SET NULL is the part that is important to you. This says that whenever any item in the referenced table (team in this instance) is deleted, then all rows in this table that had that team id should set that field to null — exactly what you’re looking for.

    Be aware that this will only work if you are using the InnoDB database engine (not the MyISAM engine). You can probably change that through phpmyadmin somewhere (I’m not familiar with phpmyadmin so I can’t help you on the details).

    Also be aware that for this to work, MySQL must actually be able to “SET NULL” — the field containing the foreign key with this constraint can’t be set to “NOT NULL” or it will fail with an error saying to “check data type”.

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

Sidebar

Related Questions

have 2 questions : A computer with 32-bit address uses 2-level page table (9
Have got a method which returns IEnumerable<User> which I have been using Linq /
Have started working my way through a book called WebGL: Up and Running, which
Have a linking (or ref) table which has a dual primary key. Need to
Have a MySQL database table with 2 columns: id, url The url column has
Have a problem, I'm about to rebuild the search feature on my site, but
Have been trying for hours - unfortunately I'm stuck on this three-table join. The
Have a numeric nvarchar values with some extra-symbols For example 1/2, 9/6, 14A They
Have a client who is looking at developing a site where clients get access
Have a question about calling one prototype function in another prototype function. for instance

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.