Error trying to DELETE with INNER JOIN in MYSQL

0
DELETE FROM 'tb_users' 
INNER JOIN 'tb_marker' ON tb_users.id_users' = 'tb_marker.id_users' 
WHERE 'tb_users.id_users' = 12

Here is the error:

  

You have an error in your SQL syntax; 'INNER JOIN' tb_marker 'on' tb_users.id_users' = 'tb_marker.id_users' WHERE' tb_u 'at line 1

    
asked by anonymous 19.04.2017 / 21:47

2 answers

5

You need to specify which table you want to exclude from the registry.

In the example, I added an alias to the tb_users table and specified that I wanted to remove the record from this table.

DELETE u.* FROM tb_users u --Para remover apenas de tb_users
INNER JOIN tb_marker m
  on u.id_users = m.id_users
WHERE tb_users.id_users = 12

It's important to note that Id is

    
19.04.2017 / 21:52
1

You need to specify which table to delete, for example:

DELETE 'tb_users' FROM 'tb_users' 
INNER JOIN 'tb_marker' 
  on 'tb_users.id_users' = 'tb_marker.id_users' 
WHERE 'tb_users.id_users' = 12

If you want to delete both, specify both.

    
19.04.2017 / 21:54