Finding a value in several fields

2

In my bank I have 3 columns for phone, I need to know if the value is in any of the 3 fields, what is the best way to assemble this select?

    
asked by anonymous 07.01.2015 / 20:52

2 answers

4

You can use a IN "reverse" (than is normally used):

... WHERE '2345-6789' IN (tel1, tel2, tel3)
    
07.01.2015 / 21:01
3

If it is a non-exact search, ie by numbers that contains a portion of the phone, you can do this:

WHERE telefone1 like '%123%'
    OR telefone2 like '%123%'
    OR telefone3 like '%123%'

Being 123 the number entered by the user in the search field.

    
07.01.2015 / 21:05