Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Subset

Status
Not open for further replies.

mcginty

IS-IT--Management
Mar 14, 2001
35
IE
Hi,

In a command button, how do I run a select query and then query the results. Ideally I don't want to create a table, can the 1st result be stored in memory and then queried?
e.g. Select id, date from table where id = '12345'
then
Select id, date from (above results) where date = '01/01/01'

Rgds,
Ted
 
Look up 'select into cursor'.

Also why are you doing two selects you could just as easily write

Select id, date from table where id = '12345' and ;
date = '01/01/01'

BTW. If your fields are not just example field names, having a field called 'date' is a bad idea. As is having any field or table name be a foxpro key word. You tend to get really wierd results at the oddest times. I once spent the better part of a day tracking down a bug that was caused by doing a select on a table with a field called date, that also used the date() function in the same query.



 
Thanks fluteplr,

The query is more complicated than example but I hadn't used into cursor before, and thanks, date was just an example field name

Rgds,
Ted
 

OK here's my problem.

I have two tables from which I want to pull out a report of new accounts for a week who have ordered a particular product_id. They are only new accounts if it's their first order of this product (prod4,5 or 6)


TableA (orders)
o_link, account_no, ord_no, o_date

TableB (order lines)
o_link, product_id


The tables are linked by a.o_link & b.o_link and there may be multiple order lines (product_id's) to each order_no.


I'm looking at something like..

store thisform.text1.value to ddate1
store thisform.text2.value to ddate2

SELECT TableA.account_no, Count(TableA.account_no) AS CountOfaccount_no, TableA.o_date FROM TableA, TableB WHERE TableA.o_link == TableB.o_link AND INLIST(TableB.o_product,'Prod4','Prod5','Prod6') GROUP BY TableA.account_no, TableA.o_date HAVING CountOfaccount_no=1 AND between(TableA.o_date,ctod(ddate1),ctod(ddate2))
 
Anyone got any ideas on the above problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top