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

How do you use the Left and Right functions in the same query 1

Status
Not open for further replies.

serino

Programmer
Feb 13, 2003
112
US
I have a table called JobTable with 1 field called Job#. The Job# field is an 8 digit number, e.g [3924020]. The below left function inserts 392 into a field called expr1. I would also like the remaining numbers [4020] to be put into their own field Expr2 using the same query below..

How do I accomplish this?

[blue]
SELECT Left([job#],3) AS Expr1
FROM [JobTable];[/blue]
 
Take a look at the Mid function in the help files.

mid([JOB#],4,5)

A wise man once said
"The only thing normal about database guys is their tables".
 



Hi,
Code:
SELECT Left([job#],3) AS Expr1, right([job#],5) AS Expr2
FROM [JobTable];


But I strongly suggest that these kinds of "numbers" are not really numbers, in all procticality. You'll never do math on such a "number".

Rather, it is an IDENTIFIER, and IDEMTIFIERS ought to be TEXT of a given length. Leading zeros ARE or can be significant. Not so with numbers.

Skip,

[glasses] [red][/red]
[tongue]
 
Thanks for both of your replies. AlexCuse, the Mid function is what I needed. Worked out Great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top