July 25th, 2007, 02:05 PM
Query/select the first 10 characters in a field
I'm comparing two tables and need to compare the first 8 characters of one field in table A to the first 8 characters in another field in table B.
So instead of where 'John Smith' = 'John Smith' it would compare where 'John Smi' = 'John Smi'
I know I've done this before but can't find a good reference.
It's something like this when calling a query within a WHILE loop:
SELECT * FROM blah WHERE FID = '".$row['FID']."' AND LEFT('TRACK', 8) = LEFT('".$row['TRACK']."',8)
Am I close? Any help would be appreciated.
July 25th, 2007, 02:46 PM
I think the single quotes there are throwing things off. And if the 2nd part is inserted in the SQL by the client application then I would truncate the string there rather than make the server do it.
July 25th, 2007, 02:59 PM
Argh... that was it... thank you!
Originally Posted by f'lar
I tried so many variations.
February 16th, 2010, 05:45 AM
Trouble with selecting characters from a field
I'm using MS Query to retrieve external data from an oracle system into excel
in the Fixed Assets Section of Oracle we have a field L58PDGLNO
This is a 7 digit number made up of a 3 digit cost centre and a 4 digit depreciation code
what i'd like to do within the query is essentially create 2 field that pull down the left 3 characters in one, and the right 4 characters in another. I can do this in excel but am trying to make our Fixed Asset Register as automated as possible.
As you may have gathered i am slightly limited as to my SQL understanding but does anyone know how i might go about this please?