SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: How can I select from 2 tables in Oracle?

  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    601
    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 silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,470
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    define "didn't work"

    syntax error?

    no syntax error, but no results?

    results, but wrong rows?
    r937.com | rudy.ca | 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
    601
    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,396
    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 :: From £250/m
    Personal Web Hosting :: Budget Web Hosting :: From £50/y
    Call 0800 542 9764 today and ask about our Cloud Hosting Platform

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,908
    Mentioned
    0 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
  •