Home » questions » Need help with Access SQL query: Urgent?

Need help with Access SQL query: Urgent?

2006-08-08 23:46:27, Category: Programming & Design
I have 2 tables. Table 1 has 2 columns: From and to having some interger values Table 2 has a column having interger values, which may or may not lie between range specified from "To" value to "From" value. I have to make a query, to count the number of entries in table 2 which lie in the range decided by "To" - "From" Please help. What is wrong with this SQL query: Update table1,table2 set table1.col1 = count(*) where ((table1.col2 > table2.col1) and (table1.col3 < table2. col1))

Answers

  1. harrypotter

    On 2006-08-09 00:33:48


    select count(*) from table1 where table1.column1 in ( select table2.column2 from table1 where table2.column2 between Input lower value and input.upper value. hope this helps
  2. weida

    On 2006-08-12 05:31:28


    You may use the access query tool "Advanced Access Builder" at http://www.download5000.com/page25449.aspx , it allows you to visually build complete SQL scripts.
  3. Indian_Male

    On 2006-08-09 00:16:05


    Table 1 (F, T) and Table 2 (V) F: From, T: To and V: Value Query: SELECT table1.F, Table1.T, Count(TABLE2.V) FROM Table1, Table2 where Table2.v >= table1.f and table2.v <= table1.t group by table1.f, table1.t; Reg. your additional details query, the normal SQL query would be: assuming C is the column to store count of values in range Update Table1 Set C = (Select count(*) from Table2 where v >= table1.f and v <= table1.t) What you have provided is wrong. You cant update two tables at a time in an Update statement.
  4. gansatanswers

    On 2006-08-08 23:52:34


    let us assume table1 has fields A,B and table2 has field C try this query select * from table1, table2 where table2.C between table1.A and table1.B