• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

Help with Where clause


I’m trying to conduct a SQL statement.  I would like to include a LIKE clause.  But instead of applying the clause to the entire string I would only like it to compare a portion of the string

For example I have this string:
CS00324522 | test1 / random text1

And from this I need to construct a WHERE statement that would find this:

CS00324522 | test1 / random text2

The | and / characters are common to all strings in the database.  However the length of the strings between each of the characters varies with each row.

I guess I need to extract everything to the left of the | characters so the SQL looks like

Where row1 LIKE CS00324522 |

Any ideas if this could be achieved?
  • 2
1 Solution
"I guess I need to extract everything to the left of the | characters"

Select left(fieldname, instr(fieldname,"|")-1) as leftbit
from table
Shinesh PremrajanEngineering ManagerCommented:
Select  * from table where left(fieldname, instr(fieldname,"|")-1) like 'CS00324522'

Hope this helps
SELECT * FROM myTable WHERE myStrFld LIKE "CS00324522*";
andyw27:  Is there a problem?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now