<p>I have two tables that I would like to join but I am getting an error from MySQL</p>

<pre><code>Table: books
bookTagNum ShelfTagNum
book1      1
book2      2
book3      2

Table: shelf
shelfNum   shelfTagNum
1          shelf1
2          shelf2
</code></pre>

<p>I want my results to be:</p>

<pre><code>bookTagNum ShelfTagNum shelfNum
book1      shelf1           1
book2      shelf2           2
book3      shelf2           2
</code></pre>

<p>but instead I am also getting an extra result:</p>

<pre><code>book1      shelf2           2
</code></pre>

<p>I think my query is doing a cross product instead of a join:</p>

<pre><code>SELECT `books`.`bookTagNum` , `books`.`shelfNum` , `shelf`.`shelfTagNum` , `books`.`title`
FROM books, shelf
where `books`.`shelfNum`=`books`.`shelfNum`
ORDER BY `shelf`.`shelfTagNum` ASC
LIMIT 0 , 30
</code></pre>

<p>What am I doing wrong?</p>

I think you want
```
```
where `books`.`shelfTagNum`=`shelf`.`shelfNum`
```
```
In order to match rows from the
```
books
```
and
```
shelf
```
tables, you need to have terms from each in your
```
where
```
clause - otherwise, you're just performing a no-operation check on the rows of
```
books
```
, since every row's
```
shelfNum
```
will be equal to its
```
shelfNum
```
.
As @fixme.myopenid.com suggests, you could also go the explicit
```
JOIN
```
route, but it's not necessary.