Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

delete with join on single table...

delete with join on single table...

delete with join on single table...

I have a query which matches records with similar 7 and 6 digit primary keys...
I wish to delete the matching 7 digit records only...
The query below returns: '#1242 - Subquery returns more than 1 row'

I know I could write a loop in PHP to accomplish this; but, would like to write a proper query in MySQL to accomplish same...

The join matches 6 digit keys to 7 digit ones with a leading '1'...



DELETE FROM `mbbgmc_eraq_ro_2016-05-03` WHERE `roid` = (
SELECT `six`.`roid`, `seven`.`roid` as x 
FROM `mbbgmc_eraq_ro_2016-05-03` as seven
INNER JOIN `mbbgmc_eraq_ro_2016-05-03` as six
ON `seven`.`roid` LIKE CONCAT('1',`six`.`roid`)
WHERE `seven`.`postdate` > '2016-03-20') as z ) 

Thanks in advance for suggestions on how to resolve...


RE: delete with join on single table...

Figured it out...
Need IN instead of =


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close