×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Select Subset

Select Subset

Select Subset

(OP)
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

RE: Select Subset

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.



RE: Select Subset

(OP)
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

RE: Select Subset

(OP)

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))

RE: Select Subset

(OP)
Anyone got any ideas on the above problem?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close