DIGIT-ARC read-only archive · snapshot: July 23, 2026

Frustrating SQL Query

2 posts · originally from https://geek.digit.in/community/threads/frustrating-sql-query.132231/

arpanmukherjee1
arpanmukherjee1 Original post #1
Sep 28, 2010 at 11:54 PM
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
manaskumar
Oct 6, 2010 at 1:57 AM
You cannot use table alias in inner query.
Replace t of inner query with train_info_submit