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