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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:13:07+00:00 2026-06-12T06:13:07+00:00

I have a question about relational databases. I know that when using this I

  • 0

I have a question about relational databases. I know that when using this I should set my foreign keys properly but I didn’t do that right away so now I have to clean up my messy database in order to remove entries with broken relations. My tables look a bit like this:

LINKS
| id | url | other, irrelevant fields |

LINK_USERS
| id | link_id | other, irrelevant fields |

It should be obvious that LINK_USERS has a relation with LINKS through the link_id field (which is the id of the entry in the LINKS table)

I’ve been messing around for a bit of time now and somehow I can’t seem to select all rows from LINK_USERS that have no reference in LINKS.

I must add here that deleting should only have happened on the LINKS table. So what I would want from the query is to SELECT all rows FROM LINK_USERS WHERE link_id cannot be found in the LINKS table.

As you might have figured, I am no MySQL guru. If my question is vague let me know and I’ll try to formulate it better.

Thanks in advance!

  • 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-12T06:13:08+00:00Added an answer on June 12, 2026 at 6:13 am

    Your question is not vague at all; you can get what you want with very simple SQL (which looks very much like your English language description of what you’re looking for):

     SELECT * FROM LINK_USERS WHERE link_id NOT IN (SELECT id FROM LINKS);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, this is not a question about how to implement inheritance in relational databases.
I have a question about how to set up the relations between two models
I've been reading a lot about Relational Databases using many JOIN statements on every
I have a relational database with about 15 tables that will be used in
the title might be too generic, but I have a very specific question about
Okay; sorry I know this isn't a programming question as such, but it was
This question asks about storing a single graph in a relational database. The solution
I have some question regarding database performance in general. I'm using Sqlite but I
I have a question about Criteria method, one-to-many relation to the database, 'one' is
Im new to rails and have a question about accessing relations of relations in

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.