[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

SQL Query Partial Values

How would I query a partial value from the database?  

TireType field values:

Hi-Performance A/S - SKU=1511000
Touring All-Season - SKU=413165507
Ultra High Performance - SKU=50059M
Ultra High Performance - SKU=500XYZ

Example query:

Select tireType
from myTires
where LEFT(myTires.TireType, PATINDEX('%- SKU%', myTires.TireType) IN ('Hi-Performance A/S','Ultra High Performance ')

I would like the results to return:

Hi-Performance A/S - SKU=1511000
Ultra High Performance - SKU=50059M
Ultra High Performance - SKU=500XYZ

Please advise on how to correct the query to return desired results.


Thank you!

Terry
0
splendorx
Asked:
splendorx
1 Solution
 
reb73Commented:
You are just missing an extra parenthesis in your where clause.. Try -
Select tireType
from myTires
WHERE	PATINDEX('%- SKU%', myTires.TireType) > 0
AND	LEFT(myTires.TireType, PATINDEX('%- SKU%', myTires.TireType) - 1) IN ('Hi-Performance A/S','Ultra High Performance ')

Open in new window

0
 
splendorxAuthor Commented:
Thanks for your help!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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