About
Pricing
Community
Teams
Start Free Trial
Log in
pepps11976
asked on
5/17/2011
SQL Query
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
Thanks
John
Microsoft SQL Server 2008
6
1
Last Comment
pepps11976
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]
5/17/2011
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Lee
5/17/2011
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.
Lee
pepps11976
5/17/2011
ASKER
Ok
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,
dbo.itran.it_recno
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
Lee
5/17/2011
where left(myfield, 3) in ('AMC', 'AMW')
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Guy Hengel [angelIII / a3]
5/17/2011
so mine worked correctly?!
pepps11976
5/17/2011
ASKER
Sorry yes i mistyped the query sorry :(
A bit more info if you could and I'll see what help I can provide.
Lee