Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 28-09-2010, 11:54 PM   #1 (permalink)
XLr8
 
arpanmukherjee1's Avatar
 
Join Date: Sep 2008
Posts: 637
Unhappy Frustrating SQL Query


how to use a value of other table as table name for another SELECT statement in Access?

i am currently using this statement

Code:
SELECT DISTINCT t.train_no, t.train_name 
FROM train_info_submit t, msg_info_submit m 
WHERE t.train_no=m.train_no 
ORDER BY t.train_no
now i have tables with table names Equal to entry in "train_info_submit"

eg- if "train_info_submit" has three trains, i will have three tables with table name equal to entry in "train_info_submit.train_no"

i have to check for row count in every table that has some values.

the query will look something like:
Code:
SELECT DISTINCT t.train_no, t.train_name 
FROM train_info_submit t, msg_info_submit m 
WHERE t.train_no=m.train_no 
    AND COUNT(***now select * from each t.train_no***)<>0  //error saying access cannot find table 't'
ORDER BY t.train_no
__________________
Quote:
There are more things in heaven and earth, Horatio,
Than are dreamt of in your philosophy.
arpanmukherjee1 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 06-10-2010, 01:57 AM   #2 (permalink)
Have fun till death!!
 
manaskumar's Avatar
 
Join Date: Mar 2010
Location: Pune, Maharashtra
Posts: 24
Default Re: Frustrating SQL Query

You cannot use table alias in inner query.
Replace t of inner query with train_info_submit
manaskumar is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Charan
- by Charan
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 03:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2