| View previous topic :: View next topic |
| Author |
Message |
Hermann Guest
|
Posted: Sun May 16, 2004 2:59 pm Post subject: How to select only first record into query? |
|
|
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
|
Posted: Sun May 16, 2004 4:15 pm Post subject: Re: How to select only first record into query? |
|
|
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
|
Posted: Sun May 16, 2004 5:31 pm Post subject: Re: How to select only first record into query? |
|
|
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
|
Posted: Sun May 16, 2004 6:52 pm Post subject: Re: How to select only first record into query? |
|
|
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
|
Posted: Mon May 17, 2004 6:05 am Post subject: Re: How to select only first record into query? |
|
|
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 |
|
 |
|