Jump to content

A query with a pattern match condition? <<ULTRA difficult Question>>


onedumbcoder

Recommended Posts

Hi guys,

 

lets say I have table with a field called code.

 

is it possible to do a query where I look at the values in code and see if a patter occurs?

 

for Example

 

code = "ABCDE"

 

and I want to see if  CDE occurs in there and if so get it, so something like this:

 

"select * from paper WHERE code has pattern CDE"

Link to comment
Share on other sites

select * from paper WHERE SUBSTRING(code, -1)= 'C'

The last argument is not needed. But the that would return anything where the value of code ends with a C.

This produces the same result:

select * from paper WHERE code LIKE '%C'

 

Link to comment
Share on other sites

Thanks for all the help so far.

 

I understand % means anything goes:  for example    %C  get everything that ends with C  C% ... that starts with C

And I guess I could even do  %C%C%?

 

Are there any one symbols used besides %? if so can you please mention them and their influence.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.