SELECT A.TRAN_ID , B.REFERENCE_DATA
FROM dbo_BSTRN_HEADER1 as B INNER JOIN dbo_BSTRN_HEADER1 AS A
ON B.[REFERENCE_DATA] LIKE A.Tran_ID & "*recl*"
If possible, make sure you have indexes on Reference_Data and Tran_ID.
Beyond that perhaps you can add a condition to Tran_Id where you specify it
must be of some minimum length.
WHERE A.Tran_ID Like "?????*"
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
Freida said:
i am actually doing
SELECT A.TRAN_ID , B.REFERENCE_DATA
FROM dbo_BSTRN_HEADER1 as B INNER JOIN dbo_BSTRN_HEADER1 AS A
ON B.[REFERENCE_DATA] LIKE A.Tran_ID & "*recl*" b/c I only want the ones
with *recl* in the reference data column but the begin numbers have to
start
with the Tran_ID number.
here is an example of what I am getting
Tran_ID Reference_Data
10 100039recl1
10 103010recl1
100039 100039recl1
103010 103010recl1
all I want is the
100039 100039recl1
103010 103010recl1
I am only supposed to have 50 records I am getting a ridiculus amount of
records when ever I click the button to go to the last record access stops
responding.
John Spencer said:
Did you try the second variation? That one should ignore length and just
match on REFERENCE_DATA starting with the characters in TRAN_ID
SELECT A.TRAN_ID , B.REFERENCE_DATA
FROM dbo_BSTRN_HEADER1 as B INNER JOIN dbo_BSTRN_HEADER1 AS A
ON B.[REFERENCE_DATA] LIKE A.Tran_ID & "*"
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
those queries almost work, but the only thing is that when I looked at
my
data some were 5 charactors and some were 6 so I tried it without the
left
function but can't seem to get it work properly. Also, I think I was
wrong
in my return example
please see updated below. Thx
column 1 Column2
22334 66555
22171 void
3425 22334recl1
44876 22171crate
774611 321156recl1
321156 774611abc
returns 22334 22334recl1
321156 321156recl1
:
I want the query to select the first record based on the
information
provided in column 2 b/c column 2 has the same number*.
SELECT dbo_BSTRN_HEADER1.TRAN_ID as a,
dbo_BSTRN_HEADER1.REFERENCE_DATA
as
b
FROM dbo_BSTRN_HEADER1
WHERE ((([a].[TRAN_ID])=Left(.[REFERENCE_DATA],6)));