Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filter the data with 2 at the back

Status
Not open for further replies.

hengsin

Technical User
Mar 26, 2003
128
0
0
MY
table: sales
field: manufacturing code

Data inside manufacturing code:
IM2, IM, SIS, SIS2, PASSO2, APC2, SeeFei2, SeeFei

I want use the SQL to display the data with 2 at the back only. I know there is a stupid to do that, i.e.

....where ManufacturingCode= "IM2" or ManufacturingCode="Passo2" or ManufacturingCode="SeeFei2" .....

Maybe there is a better way on how to do it. Any suggesstion?
 
Use:

.... WHERE ManufacturingCode LIKE '*2'

This 'wildcard *' used in conjuntion with the LIKE operator means 'match any string of characters, followed by a 2 at the end of the string.

Hope this does it


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
try the like operator

eg:
SELECT *
FROM sales
WHERE ManufacturingCode
LIKE '*[2]';

the % wildcard on the beginning of the charctrer to search it will select all values that have 2 at end and no more characters after that



_____________________________________________________________________
onpnt2.gif
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
[/sub]
 
to slow and had T in mind when I explained it with the %

_____________________________________________________________________
onpnt2.gif
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top