How would i get something from mysql that requests something like this:

Where ID=$id and ID=SubId

I know it doesn't work, they are different tables but i would like to keep it to one wuery. How would i do this?