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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:07:24+00:00 2026-05-31T13:07:24+00:00

I have to check wether two queries (e.g. an update and a delete statement)

  • 0

I have to check wether two queries (e.g. an update and a delete statement) affect the same row in a MySQL database.

I thought about selecting the affected entries of the queries with a select and check if the same row appears in both queries:

UPDATE Foo SET col = 'a' WHERE id > 5;
DELETE FROM Foo WHERE col = 'b';

SELECT (SELECT * FROM Foo WHERE col = 'b') IN (SELECT * FROM Foo WHERE id > 5);

In practice it worked for my simple Foo table, but failed in another table with several columns – even when the two sub-selects where exactly the same. Also with this solution the first sub-select can only contain one result.

Does anyone know another solution or the reason why the above select could fail with another table?

  • 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-31T13:07:25+00:00Added an answer on May 31, 2026 at 1:07 pm

    I solved my problem partly with PHP now, instead of solving it only with MySQL.

    I select the affected entries of the concerned queries and compare the result in my application (in my case it’s realised with PHP).

    Why don’t I solved it via one query over MySQL?
    At the moment were I’ve to compare the queries, I don’t know anything else given by the query. Still I know which tables are affected and which columns, but I don’t know how this tables are structured or which column is a primary key (or if there are even multiple primary keys). That’s why I, more or less, wrote my own IN function in PHP.

    Another way of solution could be to get the primary keys from MySQL (e.g. using DESCRIBE) and using the described solution of Joachim Isaksson.

    Just wanted to share this with you.

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

Sidebar

Related Questions

I'm trying to check wether two MovieClips are of the same kind or not.
I have a situation. I have two kinds of date in the mysql database.
I've got a large-ish MySQL database which contains weather information. The DB is about
In MySQL I have to check whether select query has returned any records, if
I have a hash with about 130,000 elements, and I am trying to check
I have two different way to check whether a process is still up and
I have two strings and I would like to check whether the first is
I want to check whether two vectors have any elements in common. What's wrong
I have two NSStrings named country and searchtext. I need to check whether the
I have to check to see whether two double values are equal including magnitude

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.