SQL Query

pepps11976 used Ask the Experts™
Hi all i have a query within SQL and would like to return values in a column where the first three letters are AMC and AMW,

How do i add this to my query


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
WHERE yourfield like 'AM[CW]%'
Do you mean the columns have the first 3 letters AMC and AMW or the contents of the columns have that?

A bit more info if you could and I'll see what help I can provide.




This is my query

SELECT     TOP (100) PERCENT dbo.ihead.ih_account, dbo.ihead.ih_name, dbo.ihead.ih_quodate, dbo.ihead.ih_invdate, dbo.ihead.ih_quotat, dbo.ihead.ih_invoice,
                      dbo.ihead.ih_exvat, dbo.ihead.ih_vat, dbo.ihead.ih_fcurr, dbo.ihead.ih_region, dbo.ihead.ih_terrtry, dbo.ihead.ih_raised, dbo.itran.it_anal, dbo.itran.it_status,
FROM         dbo.ihead LEFT OUTER JOIN
                      dbo.itran ON dbo.ihead.ih_doc = dbo.itran.it_doc
WHERE     (dbo.ihead.ih_quotat > ' ') AND (dbo.itran.it_recno = '1') AND (dbo.itran.it_status = 'A') AND (dbo.itran.it_anal > ' ') AND (dbo.ihead.ih_quotat > ' ') AND (DATEPART(m,
                      dbo.ihead.ih_quodate) = DATEPART(m, GETDATE())) AND (DATEPART(yyyy, dbo.ihead.ih_quodate) = DATEPART(yyyy, GETDATE()))

In the column IT_anal i need to retrieve everything that starts with AMW and AMC

angelIII i tried you code and it returned nothing there should be 12 entries

11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

where left(myfield, 3) in ('AMC', 'AMW')

Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

so mine worked correctly?!


Sorry yes i mistyped the query sorry :(

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial