# Trouble with Database lookup table

**URL:** <https://forum.cloverdx.com/t/trouble-with-database-lookup-table/983>\
**Category:** CloverDX Platform\
**Created:** [December 19, 2011, 12:00am UTC](https://forum.cloverdx.com/t/trouble-with-database-lookup-table/983 "2011-12-19T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pro7](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pro7](https://forum.cloverdx.com/u/pro7)\
**Post date:** [December 19, 2011, 12:00am UTC](https://forum.cloverdx.com/t/trouble-with-database-lookup-table/983/1 "2011-12-19T00:00:00Z")

</div>

Hi,  
I have a Database Lookup Table that is giving an incorrect result. It has a simple query with a single qualifier like this:  
Select  
CODE,  
TYPE,  
SRCE,  
DESC,  
From TableName  
Where TYPE=‘H’

It seems that the where clause is being ignored because I’m getting back all rows in the table (over 12,000) when I should only be getting back approx. 4,000 with TYPE=‘H’.  
I have the exact same SQL query in a DBInput table and I get the correct result. Any ideas?  
Thanks

---

<div class="post-metadata">

**Author:** ![pro7](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pro7](https://forum.cloverdx.com/u/pro7)\
**Post date:** [December 20, 2011, 8:55pm UTC](https://forum.cloverdx.com/t/trouble-with-database-lookup-table/983/2 "2011-12-20T20:55:40Z")

</div>

Maybe I’m just not understanding lookup tables very well… will look for some examples of how to use.

---

<div class="post-metadata">

**Author:** ![stysm](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@stysm](https://forum.cloverdx.com/u/stysm)\
**Post date:** [December 21, 2011, 1:34pm UTC](https://forum.cloverdx.com/t/trouble-with-database-lookup-table/983/3 "2011-12-21T13:34:07Z")

</div>

Hi pro7,

From what you are saying, I suppose you were using [LookupTableReaderWriter](http://www.cloveretl.com/documentation/UserGuide/topic/com.cloveretl.gui.docs/docs/lookuptablereaderwriter.html?resultof=%22%6c%6f%6f%6b%75%70%22%20%22%74%61%62%6c%65%22%20%22%72%65%61%64%65%72%22%20). In general, this is not the best component for reading from databases. Instead, please use DBInputTable as you have already found out.

Moreover, it is not that you do not understand lookup tables, but our documentation is not clear about them sometimes. LookupTableReaderWriter is not meant for writing with **DB lookup tables** at all (with reading not working reliably, either). You may notice we have already raised an [issue about this](https://bug.javlin.eu/browse/CLDOC-264) and will pay attention to it soon.

We hope this helps you when working with CloverETL.
