Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Joining Tables

Joining Tables

Scheduled Pinned Locked Moved Database
questiondatabase
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Greeky
    wrote on last edited by
    #1

    Imagine two table One Table (ForeignCurrency) FC_ID FC_TYPE 1 USD 2 EUR 3 YTL Other table (Rates) FCV_ID FCV_RateIN FCV_RateOUT FCV_DATE 1 1 1 10/13/2005 2 1.345 1.346 10/13/2005 3 1.651 1.654 10/13/2005 I need to join two table in a one query. I do this so Select FC.FC_TYPE,ISNULL(FCV_RateIN,1) FCV_RateIN,ISNULL(FCV_RateOut,1) FCV_RateOut from ForeignCurrency FC LEFT OUTER JOIN Rates R ON FC.FC_ID=R.FCV_ID WHERE FCV_Date='10/13/2005' This give me result as i want. But when i need 10/14/2005 rates it give me empty result set , but i expect FCV_TYPE FCV_RateIn FCV_RateOUT YTL 1 1 USD 1 1 EUR 1 1 How can i re-write code ?

    M 1 Reply Last reply
    0
    • G Greeky

      Imagine two table One Table (ForeignCurrency) FC_ID FC_TYPE 1 USD 2 EUR 3 YTL Other table (Rates) FCV_ID FCV_RateIN FCV_RateOUT FCV_DATE 1 1 1 10/13/2005 2 1.345 1.346 10/13/2005 3 1.651 1.654 10/13/2005 I need to join two table in a one query. I do this so Select FC.FC_TYPE,ISNULL(FCV_RateIN,1) FCV_RateIN,ISNULL(FCV_RateOut,1) FCV_RateOut from ForeignCurrency FC LEFT OUTER JOIN Rates R ON FC.FC_ID=R.FCV_ID WHERE FCV_Date='10/13/2005' This give me result as i want. But when i need 10/14/2005 rates it give me empty result set , but i expect FCV_TYPE FCV_RateIn FCV_RateOUT YTL 1 1 USD 1 1 EUR 1 1 How can i re-write code ?

      M Offline
      M Offline
      miah alom
      wrote on last edited by
      #2

      If you want the resultset independent of the FCV_DATE column just remove it from the where clause. Since there is no column with FCV_Date='10/14/2005' you get an empty resultset.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups