Link to home
Start Free TrialLog in
Avatar of Curtis Long
Curtis LongFlag for United States of America

asked on

SQL 2008 query

I have a table called plants a column called contract.

In this column I have numbers like the following:

1547ac
154667ac
1445478acd
1245acd
1245ar

I need to write a query that will return all contracts with ac in them.

I know that if I had just the ac or acd etc in the column I could write a query as follows:

select contract
from dbo.plant
where contract ='ac'

But how can I get all contracts with ac in them even if the first portion of the column is anywhere from 4 to 10 numbers then the letters??

Thanks,


SOLUTION
Avatar of Ariful Ambia
Ariful Ambia
Flag of Bangladesh image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Curtis Long

ASKER

Thanks!!  

Except one small thing, that returns ac AND acd.  How can I exclude acd??
you can use the LIKE operator

WHERE contract LIKE '%ac%'
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial