computer
 






 

Question by  bvolkel (32)

How do I select subselect as a table in SQL?

 
+6

Answer by  Manny95 (35)

If you have two tables or more, you want to do a sublect: the clause which resolves the subquery. Select * from table1 where table1.field = (select field1 from table2)

 
+5

Answer by  gigo (1706)

The best thing is to formulate the sub query in a view. you can write create view "view name" as select ... from ... where ... in select ... from ... where ... . After you have created this view, you can use it like a table or export it in a second step into a real table.

 
+5

Answer by  reflex (278)

You right click whatever you are trying to subselect and highlighting it. Then right click and click the subselect function.

 
+5

Answer by  SpaceMunkee (245)

You will need to use a SELECT statment, and then use a FROM or WHERE statement to make a subquery.

 
+5

Answer by  crambo (117)

Take a look at the following example: SELECT * FROM (SELECT * FROM T_TABLE_NAME) TBL The subquery is being given an alias of TBL and treated as a table by the outer query. You can repeat this technique and query from subqueries that contain more subqueries. See the following: select * from (select * from (select * from t_table_name)tbl1)tbl2

 
+4

Answer by  Silvio (61)

Depending on RDBMS which you use, you can use the next syntax select an_alias.* from ( select * from my_table_subselect ) an_alias This works fine in Oracle or Postgres.

 
+4

Answer by  ASHAH (4)

Query : SELECT CustomerID, CustomerName FROM Customer WHERE CustomerID IN ( SELECT Order_Master_CustomerID FROM Order_Master WHERE OrderDate > DateAdd (date,-7, getdate())

 
+3

Answer by  BL99 (54)

Put the "subselect" query in a pair of parentheses: (), treating it as a table name in the main "select" query. For example: select * from (select.... ) where...

 
+2

Answer by  japratt (1687)

If you are wanting to select this type of function you will need to go and add that button to the toolbar.

 
You have 50 words left!