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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:16:01+00:00 2026-05-25T00:16:01+00:00

I have the following MySQL query, which I’m using with PHP (5.2). DELETE t1.*,

  • 0

I have the following MySQL query, which I’m using with PHP (5.2).

DELETE t1.*, t3.* FROM 
            forum_posts AS t1,
            forum_topics AS t2,
            user_points AS t3
WHERE  t1.topic_id = t2.topic_id
       AND t2.deleted = 1
       AND t1.post_id = t3.id
       AND t3.type = 'post'
       AND t1.post_author = t3.profile_author  

However it’s not functioning how I’m intending it too (nothing happens!), let me explain:

What I intend the query to be doing is to delete all rows in the forum_posts table and/or (I’m saying “and/or” because it will depend if the rows even exist) delete all rows in the user_points table => [if the topic in which the post was created has been deleted (for your info to avoid confusion it’s really just “hidden”, we determine this by checking if it equals 1)].

I hope the query structure explains it self, the topic_id is mainly used to JOIN the the tables together.

The query runs fine (gives no MySQL or PHP errors, so I would assume the syntax is fine?), I’ve checked the DB and theres topics which exist which are deleted (the deleted column is set to 1) and theirs post which exist aswell for those topics (so it’s not the case that there is no data).

Appreciate all replies.

  • 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-25T00:16:02+00:00Added an answer on May 25, 2026 at 12:16 am

    I have a personal preference of always specifying the joins explicitly instead of lumping everything in the where clause. This also helps in visualizing where you might need a LEFT join.

    DELETE forum_posts t1, user_points t3
        FROM forum_posts AS t1
        INNER JOIN forum_topics AS t2 ON t2.topic_id = t1.topic_id
        INNER JOIN user_points AS t3 ON t3.id = t1.post_id
            AND t3.profile_author = t1.post_author
            AND t3.type = 'post'
    WHERE t2.deleted = 1
    

    Now, based on your statement, I’d suggest changing the second INNER JOIN to a LEFT JOIN:

    DELETE forum_posts t1, user_points t3
        FROM forum_posts AS t1
        INNER JOIN forum_topics AS t2 ON t2.topic_id = t1.topic_id
        LEFT JOIN user_points AS t3 ON t3.id = t1.post_id
            AND t3.profile_author = t1.post_author
            AND t3.type = 'post'
    WHERE t2.deleted = 1
    

    I hope that helps!

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

Sidebar

Related Questions

I have the following mysql query which I am running with php like so.
I have the following simple MySQL query, called from PHP: SELECT foo_id, SUM(number_of_guests) FROM
I have the following MySQL query that I execute from a .php page SELECT
I have the following MySQL query and tables from which I am querying: SELECT
I have the following query which works fine with MySQL but refuses to work
I have the following MySQL query: SELECT value_1, ( SELECT value_4 FROM table_1 WHERE
We have a query(mysql) which returns data in the following format of alphabets followed
I have the following MySQL query: SELECT Project.*, `trk_deleted`, `trk_status`, `trk_state` FROM `project` AS
I have the following MYSQL query which when executed shows me all the invalid
I currently have the following MySQL query, which executes fine without any errors: SELECT

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.