SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I select from 2 tables in Oracle?

    Hello,

    The fallowing didn't work for me:

    Code:
    SELECT * FROM AccessLog as a, pr_departments as d WHERE a.lid = d.description;
    What;s the problem?

    Thank you.
    Why It Doesn't Work?!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    define "didn't work"

    syntax error?

    no syntax error, but no results?

    results, but wrong rows?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    acullay it worked after trying serveral hours :S
    Why It Doesn't Work?!

  4. #4
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From my experience with Oracle (Was a few years back), it'll have been the AS keyword, as I don't think Oracle supports it for creating aliases, you just simply put the alias name you want after the table name e.g.

    SELECT * FROM AccessLog a, pr_departments d WHERE a.lid = d.description;
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Karl is correct. The As keyword in oracle is for renaming / aliasing a column.
    e.g. select ename, sal*12 as AnnualPay from emp

    replaces sal*12 with AnnualPay as the column heading.


Bookmarks

Posting Permissions

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