report problem

  • hello

    this is imple inner join query

    declare @t table (id int not null identity(1,1),x int ,y int,z int,v int)
    declare @f table (id int not null identity(1,1),name nchar(20))
    insert @t values(1,0,0,0)
    insert @f values('Black'),('James')
    select * from @t t inner join @f f on t.id=f.id

    give me this result

    id          x           y           z           v           id          name
    ----------- ----------- ----------- ----------- ----------- ----------- --------------------
    1 1 0 0 0 1 Black

    (1 row(s) affected)

    but how can i give this result ?

                      name          values
    -------------------- ------
    Black x y z v
    1 0 0 0

    this is sub column

    have any method giving this result?

  • i hope i am not reading this wrong, but it looks like what you want to do is instead of using SELECT *, to select explicit column names.

    good job on aliasing all your tables!

    the second query I appended returns the desired result; side by side, i hope you see the difference.

     

    declare @t table (id int not null identity(1,1),x int ,y int,z int,v int)
    declare @f table (id int not null identity(1,1),name nchar(20))
    insert @t values(1,0,0,0)
    insert @f values('Black'),('James')
    select * from @t t inner join @f f on t.id=f.id
    select
    f.name,
    t.x,
    t.y,
    t.z,
    t.v
    FROM @t t inner join @f f on t.id=f.id

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply