0

I want to match multiple patterns from a table.

I have five different names and query should fetch all records that have those name/string listed.

Regards, Nawab

1
  • Your question is not clear, perhaps add some details and some of your code so that anyone can help. Commented Oct 29, 2014 at 8:00

2 Answers 2

2
SELECT * FROM mytable where mycolumn in ('Name1','Name2','Name3')

If you are pattern matching with wildcards you need something like:

   SELECT * from mytable 
    WHERE mycolumn LIKE'%name1%' 
    OR mycolumn LIKE'%name2%' 
    -- add more OR conditions
Sign up to request clarification or add additional context in comments.

Comments

0
Select * from mytable where columnname like pattern
union 
Select * from mytable where columnname like pattern;

For matching the multiple pattern, simply replace the pattern

Select name,id from emp where name like 'A%'
union 
Select name,id from emp where name like 'Z%'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.