Making a query

This example demonstrates how the CONTAINS function searches for text in column comment in table texttab. It returns 1 if the text satisfies the search argument, otherwise it returns 0.

SELECT AUTHOR,TITLE
        FROM DB2EXT.TEXTTAB
        WHERE CONTAINS(COMMENT, '"book"') = 1

In this example, you search for the term book in the column COMMENT.

Note

To increase performance, it is beneficial to add restrictive search criteria, for example:

SELECT AUTHOR,TITLE
        FROM db2ext.texttab
        WHERE CONTAINS(COMMENT, '"book"') = 1 AND PRICE < 20