Application Development 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: 

What is the defference between select single * from and select * from Where

Former Member
0 Kudos

What is the defference between select single * from and select * from Where

which is prefferable and best one.

9 REPLIES 9

Former Member
0 Kudos

Hi,

Select single * fetches single entry from table which matches the condition in 'where' clause whereas select * from table fetches all the records which match the data in 'where' clause.

If one wants to check if atleast one entry exists for the given criteria, first one can be used else second one is preferred.

Thanks

Vasudha

Former Member
0 Kudos

HI,

Select * means for Retriving all data based on where condition.

But Select Signle * means for extrating only one record .

Mainly Select Single * for Conditional purpose for example

By the time of cheking data is there or not in that table .

THX

former_member188827
Active Contributor
0 Kudos

select single * is preferrable.

select * works as loop and retrieves all records dat match ur condition in where clause.. its time consuming...

so if u need only 1 record dat matches ur condition use select single *.. it will search database and as soon as it finds first record dat matches ur search criteria it 'll deliver it.. n dere wont b ny further accesses to database...

0 Kudos

moreover use * if and only if u need all fields from database coz it also makes data retrieval slow..

wenever possible giv field list in order in which dey appear in dicitionary ..dis is faster.

select vbeln posnr....from vbrp where....

Former Member
0 Kudos

Hi,

select single * from will retrive only one record in a table

select * from will retrieve all records in a table

Regards

Former Member
0 Kudos

Hai,

*Difference Between Select Single and Select * from table UpTo One Rows:*

According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.

select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.

The best way to find out is through sql trace or runtime analysis.

Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.

The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.

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.

Mainly: to read data from

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, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

Former Member
0 Kudos

Hi Phani

select single * from will give you the entire first record, that means only one record will be retrived

where as select * from will retrive all the records of that particular table.

and coming to the best one, that depends upon your requirement, if they ask for only one record then we use select single, and when they want all the records we will go for select *.

hope this is clear

reply if u want more explanation on this.

former_member402443
Contributor
0 Kudos

Hi Phani,

SELECT *

vs.

SELECT SINGLE *

If you are interested in exactly one row of a database table or view, use the SELECT SINGLE statement instead of a SELECT * statement. SELECT SINGLE requires one communication with the database system whereas SELECT * requires two.

Regards

Manoj Kumar

Former Member
0 Kudos

hi phani,

When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times.