I have a table A, and it contains 10 rows and 3 columns. One of the columns is name
and these are table names.
I have written a query
select name from A
Now iIwant to use the value of all 10 names (as table names) in other query. How开发者_如何学编程 can I do this in Sybase?
You can use a result set for a JOIN
SELECT [B].*
FROM [B]
INNER JOIN (SELECT [Name] FROM [A]) aliasA
ON [B].[Name] = aliasA.[Name]
or you can use a result set for a WHERE
SELECT [B].*
FROM [B]
WHERE [B].[Name] IN
(SELECT [Name] FROM [A])
You can also use it in a variety of other ways. In most scenarios you can treat a result set as though it were a table - select from it, join with it, etc.
精彩评论