SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL -Joining table

    Hi all...

    I have 3 tables here with the columns as below:

    ADDR - cifkey(PK), addr1,addr2,addr3,addr4,addr5,postcd
    CIF- cifkey(PK), cust_id(PK)
    TEMP - cust_id(PK)

    I have a program to insert record at TEMP table which having cust_id as primary key. With the cust_id, I would like to retrieve address and postcode from table ADDR and return back to the program. The selection should based on the cifkey and cust_id among these 3 tables.

    I have come out a basic SQL as below and would like to seek for advice..

    select a.addr1,a.addr2,a.addr3,a.addr4,a.addr5,a.postcd from ADDR a, CIF b, TEMP c where a.cifkey=b.cifkey and b.cust_id= c.cust_id

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by devil_vin View Post
    I have come out a basic SQL as below and would like to seek for advice..
    what advice would you like to have?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    what advice would you like to have?

    i would like know whether the SQL is feasible enough to retrieve what I wanted to achieve.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    okay, that's fair

    what happened when you tested it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •