Friday, May 30, 2014

FIND_IN_SET vs IN SQL commands

IN
This keyword is used to get data values equals to IN clause values.

Example :-

Select * from test_table where field_1 IN ('123','abc','873','345')

Above SQL returns values equals to 123,abc,873,345 in field_1.

FIND_IN_SET

Suppose you have a String values like "123,abc,873,345". You can use FIND_IN_SET to get IN clause supported string as '123','abc','873','345'.

Select * from test_table where field_1 FIND_IN_SET (',','123,abc,873,345')

This SQL is also return above IN SQL results.

Check highlighted values.

No comments:

Post a Comment