‎2007 May 22 4:24 AM
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.
‎2007 May 22 4:26 AM
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.
‎2007 May 22 4:29 AM
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)
‎2007 May 22 4:33 AM
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
‎2007 May 22 4:34 AM
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.
‎2007 May 22 4:34 AM
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