JohnS
JohnS

Reputation: 89

SQL Select Query with like condtion

Image

I have to select Query

Table:- TableName
column-1:- FirstColumn (text)
Column-2:- SecondColumn (4-digitnumber,4-digitnumber)

like text = "Checking"
like Number = 2261 2265 2630 2659

Select  * 
From    TableName 
Where   FirstColumn '%checking%' 
And     SecondColumn'%2261%' 
Or      SecondColumn'%2265%' 
Or      SecondColumn'%2630%'

Need to select the CHECKING TEXT where Second Column 2261 and other three numeric.

Upvotes: 0

Views: 81

Answers (1)

Gurwinder Singh
Gurwinder Singh

Reputation: 39477

You probably want to wrap all the ORs in a single bracket. also, use LIKE

Select  * 
From    TableName 
Where   FirstColumn like '%checking%' 
And     ( SecondColumn like '%2261%' 
Or      SecondColumn like '%2265%' 
Or      SecondColumn like '%2630%');

Upvotes: 2

Related Questions