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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query in Foxpro 2.6

Status
Not open for further replies.

girish

Programmer
Oct 24, 2000
6
IN
There is a dbf having 2 fields; 1.Age (N 2) and 2.Name (C 30). I want to run a sql query by which i can get result in following form (using sql query):
Agea Name Ageb Name Agec Name Age(n) Name(n)
20 xxx 30 abc 5 hhh
24 aaa 31 sss 6 iii
22 bbb 39 ttt 7 jjj
21 ccc 32 kkk 8 mmm

Agea=between(age,20,30)
Ageb=between(age,30,40)
Agec=between(age,1,10)
Please guide me.
Thanks in Advance
Girish
 
If you want both Agea, Ageb and Agec on one line you'll have a number in only one of the 3 Age columns.

As you put it in your example isn't possible by using sql query.

You'll have to write a program that fills the 3 columns and prints them when all 3 are filled.

Rob.
 
Girish,
I've found a way to do it with sql:

Here it is:
Code:
select age as age1, name from age where age between 20 and 30 into cursor x1
select age as age2, name from age where age between 31 and 40 into cursor x2
select age as age3, name from age where age between 1 and 10 into cursor x3
select age1,x1.name,age2,x2.name,age3,x3.name from x1,x2,x3
 
Note that I've called the dbf with age and name in it AGE
and Agea, ageb, agec I've called Age1,age2 and age3

Rob.
 
I don't understand what you're looking for. What's the relationship between the different columns on a single line?

Tamar
 
Hi Tamar,

He probably just wants a table looking like that.

He's also not very responsive (yet)

Rob.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top