how can I build 2 queries in 1 query(VB SQL query) 
Author Message
 how can I build 2 queries in 1 query(VB SQL query)

SELECT query1.name,  table2.add1, table2.add2
FROM table2
INNER JOIN  (select table1.name,  table1.id1*100 as id100 from table1) as
query1 ON table2.id2 = query1.id100;

Or you can just use a WHERE condition, not a join:

SELECT table1.name, table2.add1, table2.add2
 FROM table1, table2
WHERE (table2.id2)=[table1].[id1]*100"

I can't think of a good reason to have the id in table2 100 times a counter
value in the first place, though....

HTH,

Max


Quote:
> I am thinking to build a query in Ms VB to sort the database

> I have 2 tables in Ms access database,

> table1
> id1  name
> 1    abcd
> 2    defg
> 3    ghij
> 4    xhxk
> 5    fgdj

> table2
> id2  add1   add2
> 100  fsjs   jfkh
> 200  dfgg   ghfg
> 300  dfgh   jyuj
> 400  yuuy   jghj
> 500  jlas   adad

> can I use VB SQL query to link this 2 table, set table1.id1*100=table2.id2

> I tried below query, but doesn't work.

> query1= select table1.id1,table1.name, [id1]*100 as id100 from table1

>     Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=test.mdb;Persist Security Info=False"
Quote:
>     Adodc1.RecordSource = "select (query1).name, table2.add1, table2.add2
> from (query1) inner join table2 on (query1).idd100=table2.id2"
>   Set obj1 = Adodc1.Recordset

> anybody can help to build this query in VB. please also forward a message


- Show quoted text -



Thu, 19 May 2005 12:20:21 GMT  
 how can I build 2 queries in 1 query(VB SQL query)


Quote:

> I can't think of a good reason to have the id in table2 100 times a
> counter value in the first place, though....

... and I'd love to see the CONSTRAINT clause that defines the
relationship!

Tim F



Fri, 20 May 2005 01:33:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB Query vs SQL Query Analyzer Speed?

2. SQL Query - MAX, Grouping and Sub query

3. SQL query works, Crystal query doesn't

4. Using Sub Query in Sql Query - Crystal Report 5.0

5. Help on building an SQL query

6. Dealing with single quotes when building an SQL query

7. Need ocx with GUI tool to build SQL queries

8. Building SQL queries

9. Dealing with single quotes when building an SQL query

10. Query calling query - how do you do this in VB

11. Query calling query - how do you do this in VB

12. Query takes 0 seconds in Query Analyzer, times out in VB

 

 
Powered by phpBB® Forum Software