Re: What's the Access equivalent for this SQL Server query?
- From: "Jason Lepack" <jlepack@xxxxxxxxx>
- Date: 9 Apr 2007 05:17:24 -0700
Umm, then maybe you should include all the information in your post??
I see that you've posted on Google Groups or some other forum and
you've made the assumption that everyone does the same. Most people
receive these messages through a news reader and therefore don't even
look at your original post because it's in another thread. Keep your
posts about one topic in one thread and that'll keep people all on the
same page.
Now, to your question.
SELECT cancelled
FROM (
SELECT TOP 1 cancelled
FROM tbl_orders
WHERE id_emp = 20
ORDER BY ID DESC)
WHERE cancelled = 0
The subquery selects the most recent cancelled and the query will only
return one record if the subquery returns a true value. I wouldn't
waste the server's time with this though. I would only use the
subquery and let the client handle that itty-bitty check.
Cheers,
Jason Lepack
On Apr 9, 7:27 am, "Oscar" <o...@xxxxxxxxx> wrote:
MH,
You're missing a lot man.
First of all, I need to find the latest entry in the table (ORDER BY ID
DESC) for the specific employee.
After that I need to verify whether the value of the field cancelled=0. This
all needs to be done within one query.
Oscar
"MH" <n...@xxxxxxxxx> schreef in berichtnews:e0rkTkpeHHA.3960@xxxxxxxxxxxxxxxxxxxxxxx
SELECT cancelled
FROM tblOrders
WHERE ID_emp=20 AND cancelled=0
Not sure what the subquery is all about, unless I'm missing something?
MH
"Oscar" <o...@xxxxxxxxx> wrote in message
news:eLRK3loeHHA.5044@xxxxxxxxxxxxxxxxxxxxxxx
What's the Access equivalent for the SQL Server query :
"SELECT cancelled FROM (SELECT cancelled FROM tblOrders WHERE ID_emp=20
ORDER BY ID DESC) WHERE cancelled=0"
The compiler fires an 'Error in FROM clause'- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- References:
- Prev by Date: Re: What's the Access equivalent for this SQL Server query?
- Next by Date: Re: optimizing ORDER BY query for Access
- Previous by thread: Re: What's the Access equivalent for this SQL Server query?
- Next by thread: Re: What's the Access equivalent for this SQL Server query?
- Index(es):
Relevant Pages
|