SQL 2 is the problem.
I believe, if my sources are correct, that you cannot have a subquery in php/mysql.
Meaning, you need to take the "( SELECT name FROM tb02 )" out.
If you assign part of the query to a variable, I think you can then use that variable in place of the subquery.
The problem of course is there is slightly a higher chance that one table will change inbetween querys, leading to an unwanted result.
The chance is so small however, and the worst that could happen is you fail to collect all the info you wanted on that particular call.