Join DELETE in MySql? How?

I have it:

$query="DELETE FROM classified, $sql_table WHERE classified.ad_id = '$id' AND classified.classified_id = $sql_table.classified_id AND classified.poster_password='$pass'";

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 classified.ad_id = 'Bmw_M3_E46_Full_29920' AND classified.cla' at line 1

Any help?

As you can see, $ sql_table is bound to a declaration table with fields. classified_id I need to attach DELETE somehow.

A basically classified table is a main table, then each category has its own tables with data about vehicles. the classified table has a field called split_id that matches the name

Here is the complete request:

DELETE FROM classified, vehicles WHERE classified.ad_id = 'Bmw_M3_E46_410811305' AND classified.classified_id = vehicles.classified_id AND classified.poster_password='some_password'

Why is this not working? Should it be so hard to remove from multiple tables?

thank

+3
source share
4 answers
DELETE a, b FROM
classified as a, $sql_table as b
WHERE
classified.ad_id = '$id' 
AND classified.classified_id = $sql_table.classified_id 
AND classified.poster_password='$pass'";

Source: Source

+1
source

MySQL , DELETE:

:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
  tbl_name[.*] [, tbl_name[.*]] ...
  FROM table_references
  [WHERE where_condition]
0

First, check the syntax for deleting multiple tables. You need to specify the tables from which to delete

DELETE classified.*, vehicles.* FROM classified, vehicles
0
source

I just discovered something, but did not know that it really works or not, try first setting what you want to link to the two tables as follows:

 DELETE FROM classified, vehicles WHERE classified.classified_id = vehicles.classified_id
AND classified.ad_id = 'Bmw_M3_E46_410811305' 
AND classified.poster_password='some_password'

it is only that exact value in the column that you want to delete. try n go back.

0
source

Source: https://habr.com/ru/post/1742144/


All Articles