Re: Tough query (for me)
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 21:18:16 -0500
Thom wrote:
I have a table of books with the following fields:1. Never ask a query/database-related question without telling us the type
ID (unique)
Author
Title
Sold (y/n)
Overstock (y/n)
I want to write a query that will show me, for each book marked sold,
if there are any in overstock.
My query is:
SELECT Table_02.Author, Table_02.Title, Table_01.Index AS SoldIndex,
Table_02.Index AS Remain_Index, Table_02.OverStock
FROM Books AS Table_01, Books AS Table_02
WHERE
Table_02.Author=Table_01.Author And
Table_02.Title=Table_01.Title And
Table_01.Sold=True And
Table_02.Sold=False
but it gives me the sold book as many times as there are overstock
books and not at all if there are no overstock books.
I will be doing the query in vb but that is not my problem . . .
My problem is writing the query in the first place.
Thanks
Thom W.
;
and version of database you are using. It is almost always relevant.
2. Show us a few rows of sample data (in tabular form) and indicate the rows
(again in tabular form) you want the query to retrieve. It also helps to
show (again in tabular form) the results you are getting from your latest
attempt and describe what is wrong with those results.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Prev by Date: Re: VB6.0 / ADO / Parameterized Query / SQLServer 2000 -- help...
- Next by Date: Re: OleDbConnectionString Vista
- Previous by thread: RE: VB6.0 / ADO / Parameterized Query / SQLServer 2000 -- help...
- Next by thread: Re: OleDbConnectionString Vista
- Index(es):
Relevant Pages
|
|