BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to select only first record into query?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Hermann
Guest





PostPosted: Sun May 16, 2004 2:59 pm    Post subject: How to select only first record into query? Reply with quote



Hi all,

I want the query only returns one record, because
I use into clause in select statement to get
returned parameters.
Is "select distinct ..." a correct method?

Thanks in advance

Hermann


Back to top
Bill Todd (TeamB)
Guest





PostPosted: Sun May 16, 2004 4:15 pm    Post subject: Re: How to select only first record into query? Reply with quote



It is very difficult to answer database questions when you do not tell
us what database and version you are using.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Hermann
Guest





PostPosted: Sun May 16, 2004 5:31 pm    Post subject: Re: How to select only first record into query? Reply with quote



Hi bill,

I use dbexpress to access ms sql server 2000 database.
the query uses TSQLQuery component.

TIA

Hermann

"Bill Todd (TeamB)" <no (AT) no (DOT) com>
??????:tr4fa0luu9cinjm72e60krf72dllvem10h (AT) 4ax (DOT) com...
Quote:
It is very difficult to answer database questions when you do not tell
us what database and version you are using.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)



Back to top
Bill Todd (TeamB)
Guest





PostPosted: Sun May 16, 2004 6:52 pm    Post subject: Re: How to select only first record into query? Reply with quote

SELCT TOP 1 CompanyName from Customer
ORDER BY StartDate

See TOP in Books Online.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Robert MacLean
Guest





PostPosted: Mon May 17, 2004 6:05 am    Post subject: Re: How to select only first record into query? Reply with quote

Hermann <herman.wz (AT) mail (DOT) com> wrote:
Quote:
I want the query only returns one record
In MySQL use LIMIT and in SQL Server use TOP


Quote:
Is "select distinct ..." a correct method?
Yes and No, distinct is for selecting records based on something distinct. So

say you had a key field and did a distinct with that it should return 1 value.
But it can give multiple row answers as well.


--
Robert MacLean
http://www.sadev.co.za



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.