有两个表tables和formTabletables(tableName(Varchar,唯一),userID,tableState);formTableN(formID,formName,UI,.....)表名formTableN是随机生成的,然后存储在表tables里面,先如何查出userID=‘a’对应的表formTable里面内容,即
通过userID查找tableName,将结果做为select * from 的数据from源 下面这个是错误的"select * from  'select tableName from tables where userID='a' '"

解决方案 »

  1.   

    分步来咯
    select tableName from tables where userID='a'
    先找到表名
    然在select * from 上面查到的表名
      

  2.   

    这个是可以的,对,但是这样就需要两次连接查询,有没有更好一点的方法呢,一个sql语句就可以的呢,请大家帮忙
      

  3.   

    存储过程可以动态执行sql,你把要执行的语句拼成字符串,然后execute immediate sql
      

  4.   

    [code=SQL][
    select * from (select tableName from tables where userID='a') q
    /code]
    这样就可以了。
      

  5.   


    select * from (select tableName from tables where userID='a') q这样就可以了。