[EMAIL PROTECTED] wrote:
Thanks for the reply. The main aim is to select the first record or
the last record. Is there any direct command for these. Please help me
in this.
There is no first or last unless there is a sort order.
To get the first row:
select * from table
order by col1
limit
Hello.
Usually such things are done in several steps using temporary table.
create temporary table memp(m int);
insert into memp select min(id) from emp;
select emp.* from emp,memp where id=m;
See:
http://dev.mysql.com/doc/mysql/en/example-Maximum-column-group-row.html
Hi,
I
[EMAIL PROTECTED] wrote:
I need to get all the details of an employee whose salary is the lowest.
I can do like this in Oracle
select * from emp where id = (select min(id) from emp).
Can we have any alternative in MySQL for the above query, as sub queries
are not supported in MySQL 4.0.21
There is
You could also do it like this:
select min(id) from emp;
Roger Baklund wrote:
[EMAIL PROTECTED] wrote:
I need to get all the details of an employee whose salary is the lowest.
I can do like this in Oracle
select * from emp where id = (select min(id) from emp).
Can we have any alternative in MySQL
Or.. Select * from emp order by id asc limit 0,1 if you want to fetch
all details.
-Original Message-
From: Jason McKnight [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 01, 2004 7:21 PM
To: [EMAIL PROTECTED]
Subject: Re: Reg SubQuery
You could also do it like this:
select min(id
[EMAIL PROTECTED] wrote:
Or.. Select * from emp order by id asc limit 0,1 if you want to fetch
all details.
That was what I said, but lets take a closer look at what the original
poster asked:
I need to get all the details of an employee whose salary is the lowest.
Now, in his example he used
Roger Baklund wrote:
That leaves us with the answer from Gleb Paharenko, except the insert
query should be insert into memp select min(salary) from emp;
... and the select should be:
select emp.* from emp,memp where salary=m;
He would get all employes with the lowest salary, as opposed to:
select
To: [EMAIL PROTECTED]
Subject: RE: Reg SubQuery
Importance: High
Or.. Select * from emp order by id asc limit 0,1 if you want to fetch
all details.
-Original Message-
From: Jason McKnight [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 01, 2004 7:21 PM
To: [EMAIL PROTECTED]
Subject