Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

question on select

Former Member
0 Likes
678

I was doing a select in a program and I was selecting specific fields. I noticed that if there was more that one record with the same values in the fields that I was selecting, it would only retreive one record. I had to put a field in the select that was unique so that I could extract all of the records. Is there something that I have to code in the select statement to be able to retreive all of the records that have the same values or is it that I have to include a unique identifier in the select.

thanks in avdance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
652

This is an issue whe you SELECT using FOR ALL ENTRIES. If you check the documentation, you'll see that duplicate entries are discarded, so if you want all records, you have to make the selection unique.

Rob

6 REPLIES 6
Read only

Former Member
0 Likes
652

Not sure if I understand the questoin completely.

1. If you want distinct rows only

SELECT DISTINCT FIELD1 FIELD2 .... INTO TABLE .......

2. If you want to select all the rows

SELECT FIELD1 FIELD2 .... INTO TABLE .......

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

Former Member
0 Likes
652

Hi Timothy,

If it is that way, you can select * (Instead of specific fields) .

If you get only specific fields, whats is the point in getting duplicate records?

Regards,

Ravi

Read only

Former Member
0 Likes
652

Hi Tim,

By default SELECT will fetch all the records when there are more than one record. You can avoid it by using DISTICT addition.

But by your question I understand you want duplicate records too. You no need to write any addition for your SELECT as it fetches all the records.

If you can write the query we could help you better.

Regards

Surya.

Read only

Former Member
0 Likes
652

Hi Timothy,

There must be distinct value for atleast one field to retrieve the records having same values for differnet fileds. or else it would not b epossible in the way u want.

regards,

keerthi.

Read only

Former Member
0 Likes
652

Timothy.

Select fields into table itab from ztab.

The above should fetch all the records irrespective of duplicates...Now, as you said that it is not fetching duplicates records it can be due to defn of you internal table is it a standard table or other ? If not please check there might be a code which would deleting the adjacent duplicates and hence a single record ?

Regards

Anurag

Read only

Former Member
0 Likes
653

This is an issue whe you SELECT using FOR ALL ENTRIES. If you check the documentation, you'll see that duplicate entries are discarded, so if you want all records, you have to make the selection unique.

Rob