Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Writing a SQL statement.
Message
From
13/10/1998 17:34:47
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00146364
Message ID:
00146418
Views:
25
Jim.....

How about:
SELECT COUNT(table1.field1) AS t1,"Table1" AS table_id FROM dbc!table1 ;
  WHERE table1.field1=memvar1 ;
  UNION ;
  SELECT COUNT(table2.field2) AS t1,"Table2" AS table_id FROM dbc!table2 ;
  WHERE table2.field1=memvar2 ;
  UNION ;
  SELECT COUNT(table3.field3) AS t1,"Table3" AS table_id FROM dbc!table3 ;
  WHERE table3.field3=memvar3
????

>I am not sure how to write a SQL statement were I have 3 tables, and I want to do a count on 1 field in each table and store it in a cursor. I use a variable as a filter. I know how to write the code for 1 table, but am having troubles writing it for 3 tables. The 3 tables are not linked together in any way.
>
> SELECT COUNT(table1.field1) as t1;
> FROM dbtables!table1 WHERE table1.field1=somevarible into cursor; finalresults
>
>The variable condition is the same for all 3 tables. If someone can help me, I would appreciate it.
>
>TIA,
>Jim
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform