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

Any diffarence

Former Member
0 Likes
572

Friends,

Is there any diffarence in the result for the following two select querys?

SELECT SINGLE atbez INTO it_archive-atbez

FROM cabnt

WHERE atinn = h_atinn

AND spras = sy-langu.

and

SELECT atbez INTO it_archive-atbez

UP TO 1 ROWS

FROM cabnt

WHERE atinn = h_atinn

AND spras = sy-langu.

ENDSELECT.

Thanks & Regards,

Vaddi Bharat.

5 REPLIES 5
Read only

Former Member
0 Likes
552

The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.

The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause or lack of, applies any aggregate, ordering or grouping functions to them and then returns the first record of the resultant result set.

Read only

Former Member
0 Likes
552

there is no diffrence,

select single * - it gets single record from Data base ( Primary key is mandatory)

select up to 1 row - it gets single record from database( not mandatory)

Read only

former_member196280
Active Contributor
0 Likes
552

Ex:

ID Name

01 AA

02 AA

03 BB

04 AA

Select Single,... where name ='AA'.

it will display the first record since where condition matched.. it will don't search other records

Displays 01 AA

Now,UPTO 1 row

it fetches all 3 records and displays 1st record

It fetches....

01 AA

02 AA

04 AA

Displays 01 AA

Now think of performance wise.

In this case select single is better in performance wise...

I guess you are clear with concept... no difference both fetch the first record

Reward points to all useful answers..

Regards,

SaiRam

Read only

Former Member
0 Likes
552

Output of the both the select queries are same whereas performance wise select single is better .

select single gets the first matching entires in the database table

whereas select upto one rows selects all the entires and return the first entry as result.

Read only

Former Member
0 Likes
552

Hi Bharat,

When you have the whole primary key of the table then use select single.

If you don't have the full key then use select UP TO 1 rows.

Using these two select in above scenario will make query much faster.

Reward points if useful.

Regards,

Atish