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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:42:13+00:00 2026-05-23T19:42:13+00:00

I have 2 tables in my DB users… ID Username Randomkey 1 Dionne 938493

  • 0

I have 2 tables in my DB

users…

ID    Username    Randomkey
1     Dionne      938493
2     Liam        902303
3     James       232039
4     Sarah       320923

interests…

ID    User_ID    Interest
1     3          Army
2     3          Boxing
3     3          Tennis
4     4          Make Up

In my interests table, ‘User_ID’ is equal to ‘ID’ from my users table.

I want to write a query that when triggered, deletes the row from my ‘users’ table and at the same time deletes all data relating to the user from the interests table.

I’m unsure how to do this and I’ve had no luck with Google.

If anybody could give me some advice or at least point me where to find this information it would be a great help.

In my head I’m thinking it would be something along the lines of:

DELETE FROM users, interests WHERE ID = '$userID' AND User_ID = '$userID'
  • 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-23T19:42:14+00:00Added an answer on May 23, 2026 at 7:42 pm
    DELETE users, interests 
    FROM users 
    LEFT JOIN interests ON users.ID = interests.User_ID
    WHERE users.ID = <id>;
    

    Of course, if the interests table was InnoDB & had a foreign key constraint to users with an ON DELETE CASCADE this would be done automatically when a user gets deleted.

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

Sidebar

Related Questions

In my database I have three tables: Users: UserID (Auto Numbering), UserName, UserPassword and
I have these tables: USERS: user_ID username password email data_registered POSTS: post_ID user_ID post_title
I have two tables users(id, username, password) and user_badges(user_id, badge_id, badge_slot) I would like
I have three tables: Users, Groups and GroupsUsers User table: id: 1 username: admin
I have 2 tables: Users: Id, UserName, ... Messages: Id, MsgText, IsRead,.... I want
I have two tables Users (name, email, password, instance_id, etc...) example: james bond, james@abc.com,
I have 3 tables: users (id, name) currency (id, name) accounts (id, user_id, currency_id,
I have 3 tables users(id,name),groups(id,name) and users_groups(user_id,group_id). users and groups have many to many
I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
I have 3 tables: users: Id Login 1 John 2 Bill 3 Jim computers:

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.