Results 1 to 3 of 3

Thread: Awkward SELECT statement question

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Cool Awkward SELECT statement question

    I've got an MSAccess database with 2 tables in, with the following columns:

    Table1
    UID (number)
    Col1 (number)
    Col2 (number)

    Table2
    ID (number)
    Desc (text)

    Each entry in col1 and col2, equates to table 2's ID field. & what I'd like to return/make in an SQL command is the following

    "Grab everything from the Table1 table,
    Col1 ordered alphabetically on it's corresponding description column in table2,
    Col2 ordered alphabetically on it's corresponding description column in table2"

    How can I do this please?????!??!?!?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    Re: Awkward SELECT statement question

    Maybe something like:
    Code:
    Select t1.[UID]
         , t1.[Col1]
         , t2a.[Desc]
         , t1.[Col2]
         , t2b.[Desc]
    From Table1 t1 Inner Join Table2 t2a On t1.[Col1] = t2a.[ID]
                   Inner Join Table2 t2b On t1.[Col2] = t2b.[ID]
    Order By t2a.[Desc], t2b.[Desc]
    Maybe?
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Awkward SELECT statement question

    Cheers Chris!

    As this was access, I needed to put brackets around this so it worked, but that did the trick thanks!!!!

    Code:
    From (Table1 t1 Inner Join Table2 t2a On t1.[Col1] = t2a.[ID])
    Inner Join Table2 t2b On t1.[Col2] = t2b.[ID]

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width