SQL Server Performance

Selecting multiple columns from multiple tables

Discussion in 'SQL Server 2005 General Developer Questions' started by solreap, Sep 20, 2007.

  1. solreap New Member

    I need to select many ( around 15 columns) from 4 tables and arrange them in an order ( that i need). Some of these tables have the same column name, and other different one had tried many queries, but of no use.
    could any one suggest a query??
  2. thomas New Member

    select t1.col1, t2.col1, t3.col1, t4.col1 ... etc
    from table1 t1
    inner join table2 t2
    on t1.col2 = t2.col2
    inner join table3 t3
    on t1.col3 = t3.col3
    inner join table4 t4
    on t1.col4 = t4.col4
    where ...

  3. FrankKalis Moderator

    If you need to differentiate columns of the same name, just give them aliases such as
    select t1.col1 AS Myt1Col1, t2.col1 AS Myt2col1... etc
  4. solreap New Member

    thanks fro the prompt reply... [:)]

Share This Page