我正在尝试使用ORDER BY DESC和LIMIT从两个具有关系的表中删除.
DELETE FROM my_rel_table AS t1
LEFT JOIN my_photo_table AS t2 ON t2.typeid = t1.typeid
WHERE t1.relid = 1
AND t1.type = 1
ORDER BY t1.id DESC
LIMIT 1
Run Code Online (Sandbox Code Playgroud)
显然上面的代码不起作用,因为mysql不接受使用内部连接的顺序和限制.
表结构如下:
my_rel_table
id relid relno typeid type
int int int int tinyint
my_photo_table
typeid pos_x pos_y width height
int int int int int
Run Code Online (Sandbox Code Playgroud)