Question: This came up at work and this really just seems like a puzzle...

Query 1:

```
SELECT * FROM
SYSIBM.SYSTABLES A LEFT JOIN
SYSIBM.SYSTABLESPACE B
ON A.DBNAME = B.DBNAME
AND A.TSNAME = B.NAME
AND A.TSNAME LIKE 'HIB%'
;

```

This query does NOT filter on the `HIB%` criteria, contrary to what it LOOKS like the query should be doing. I would THINK that putting that criteria in the `JOIN` should deliver identical results. 

Query 2 works as expected:

```
SELECT * FROM
(SELECT * FROM SYSIBM.SYSTABLES
WHERE TSNAME LIKE 'HIB%') A
LEFT JOIN
SYSIBM.SYSTABLESPACE B
ON A.DBNAME = B.DBNAME
AND A.TSNAME = B.NAME
;

```

What is wrong with the first query?

Answer: 
TRY

```
SELECT * FROM SYSIBM.SYSTABLES A 
LEFT JOIN SYSIBM.SYSTABLESPACE B 
  ON A.DBNAME = B.DBNAME AND A.TSNAME = B.NAME 
WHERE A.TSNAME LIKE 'HIB%' ; 

```

When you put the condition in the left join that is used to filter the records for the join, but since is a left join it is returning all the records from table A becasue you put no conditions on that. 

Now it would have been different if the condition was on table B. The it belongs in the left join (unless it is something like B.id is null) or you will turn the query back into an inner join.
Have you tried to move the "Like"-part to a where clause?

```
SELECT * 
FROM SYSIBM.SYSTABLES A 
LEFT JOIN SYSIBM.SYSTABLESPACE B ON A.DBNAME = B.DBNAME AND A.TSNAME = B.NAME
WHERE A.TSNAME LIKE 'HIB%'
;

```