Question: So I need to do a query based on the results of another query.   
Is there a way for me to set the result of a query to a variable so I can use the result of that in another query?

Example:  

{original query} --->

```
SELECT
tablea.number

FROM tablea

INNER JOIN tableb

ON tablea.name = tableb.name

WHERE tableb.zip = '11111'

```

Now I want to use this result to then do another query:

```
SELECT *

FROM tablea

WHERE number = (results of last query)

```

I think theres a way to set the first query to a variable so that that way the second one can just use the result, just not sure how. Thanks.

Answer: 
`System.exit` if successful does not return even via throwing an exception, so the thread will never complete. This wasn't an issue before shutdown hooks.

Workaround would be to usual standard locks (or even just hack it with `new Thread(new Runnable() { public void run() { System.exit(0); }}).start();`).
It is not recommended to use System.exit() as that just terminates the JVM. There are other concurrency tools like a CountDownLatch. You could even use a finally to clean up correctly on shutdown.