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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:01:07+00:00 2026-05-15T03:01:07+00:00

Here is my query: $query=Delete b Where Exists ( Select 1 From a Where

  • 0

Here is my query:

$query="Delete b
Where Exists 
    (
        Select 1
        From a
        Where a.poster_password = '$pass'
        And a.ad_id = '$id'
        And a.classified_id = b.classified_id
    )
Delete a
Where a.poster_password = '$pass'
And a.ad_id = '$id'";

I get this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Where Exists ( Select 1 From a Where a.poster_p’ at line 2

If you need more input let me know…

Whats wrong here?

Thanks

UDPATE:

Just a Q: Do I need to specify also that a = “this table” and b = “another table” or does MySql get that by this code?

As for the new code posted where to use FROM and a terminator semicolon, wont work and give this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Delete FROM a Where a.poster_password = ‘xxxxxxxxxxxxxxxxxxxxx’ at line 10

UPDATE2:

$query="Delete FROM $sql_table
        Where Exists 
        (
            Select 1
            From classified
            Where classified.poster_password = '$pass'
            And classified.ad_id = '$id'
            And classified.classified_id = $sql_table.classified_id
        );
        Delete FROM classified
        Where classified.poster_password = '$pass'
        And classified.ad_id = '$id'";

And when I echo $query: (fordon is in this case $sql_table variable.)

Delete FROM fordon 
Where Exists 
(  
     Select 1 
     From classified 
     Where classified.poster_password = 'xxxxx' 
     And classified.ad_id = 'motorbat_166250627' 
     And classified.classified_id = fordon.classified_id 
 ); 
 Delete FROM classified 
 Where classified.poster_password = 'xxxxx' 
 And classified.ad_id = 'motorbat_166250627'

Thanks again

  • 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-15T03:01:08+00:00Added an answer on May 15, 2026 at 3:01 am

    You’re not specifying the tables to delete from. Try:

    $query="Delete FROM b
    Where Exists 
        (
            Select 1
            From a
            Where a.poster_password = '$pass'
            And a.ad_id = '$id'
            And a.classified_id = b.classified_id
        );
    Delete FROM a
    Where a.poster_password = '$pass'
    And a.ad_id = '$id'";
    

    I’ve also added in a semicolon after the end of the first DELETE query. If you want to run both at the same time, you’ll need a separator to terminate the first query, before you run the second version.

    Re. your question edit about MySQL “getting” the tables – if a and b are aliases here, then no, MySQL doesn’t know what a and b are. You’ll need to alias the tables, or replace a and b with the actual table names.

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

Sidebar

Related Questions

I have this guy: query = 'DELETE FROM boyd.%s WHERE teamid = %s AND
When I execute this query: DELETE FROM `wp_posts` WHERE id NOT IN (SELECT id
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
Here is my query Select Gender from Table The result pane shows 1 1
See, I've got this bulletin board. This query here works just fine. SELECT bulletin.date,
Here is what im trying to do explained in a query DELETE FROM table
I have a bit of a situation here. I have a query: SELECT DISTINCT
Here's the code: mysql_query(DELETE . $_GET['id'] . FROM forum_favorites WHERE thread_id=' . $_GET['id'] .
I have a query here regarding the value given to the update attribute of
I'm stuck with another coordinates related query here. I have a number of CSV

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.