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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to match the first few characters of an acct name in a query 1

Status
Not open for further replies.

Goot

Programmer
Aug 4, 2005
86
US
I have a list of account names (254 in total) that a user wants me to cross reference against our database.
If I join the two tables on the account name, it matches 2 records. I would like to match on the first x characters to see how that looks. I have been trying to do it in the query analyzer, but its not working right.

How can I match the first three characters of the name?

Thanks
 
Select table1.*, table2.* from table1 inner join table2 on
left(table1.somefield,3) = left(table2.somefield,3)
 
Trim the field from the first table, them select the trimmed field form the second table in the critera. Sort of like.....

SELECT Left([NAME],3) AS TRIMMEDFIELD
FROM TABLE1, TABLE2
WHERE (((Left([TABLE1][NAME],3))=Left([TABLE2].[LOC_NAME],3)));

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top