Hello! I want to update a table(t1) but only the rows what are in other table(t2). I try to do it, but i can. If you try to use it (it's an example,of course): UPDATE t1 SET t1.a='a' WHERE t1.b=t2.c; It won't work because, it don't know t2. But if you try something like that: UPDATE t1,t2 SET t1.a='a' WHERE t1.b=t2.c; It will be a syntax error. Some idea? Thanks in advance!! 🙂
Router
(Sorry for my english!)
update t1 set a = 'a' where b in (select c from t2)
Thank for your help, but i try to do it and it doesn't work because in mysql it doesn't exit "sub-select" and "IN" only works to search in a constant expresion, no to search in a varaible expresion. Thank you again! Some idea? Router
If you are using Mysql, my advice is to change to a real rdbms, one that supports basic SQL.
To solve this with Mysql, I think that you first need to select the values from t2 and build the delete statement dynamically in PHP.