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. SELECT and UPDATE in one statement

SELECT and UPDATE in one statement

Scheduled Pinned Locked Moved Database
databaseregexhelpannouncement
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.
  • I Offline
    I Offline
    iluha
    wrote on last edited by
    #1

    Hi everyone I'm working a program that needs to interface with a dBase 3 and pull records (sometimes limited amount) based on a zip code field. Also i need to pull the oldest records first by using MAILED field. I came up with this query to pull the data: SELECT TOP 5 * INTO DESTINATON.dbf FROM SOURCE.dbf WHERE ZIP5 = '95003' ORDER BY MAILED ASC This query works. It select top 5 record, creates DESTINATON.dbf witch is identical in structure to SOURCE.dbf and populates it with selected records. The hard part is to update the MAILED field in the same query, so next time I don't use the same records. There in no unique field that i can use to match pulled records to the SOURCE.dbf and update it. I want to do it all in one shot, but I'm not sure that this is possible. I'm using ADO 2.7 Any help is greatly appreciated. Thank you Ilya :eek:

    J 1 Reply Last reply
    0
    • I iluha

      Hi everyone I'm working a program that needs to interface with a dBase 3 and pull records (sometimes limited amount) based on a zip code field. Also i need to pull the oldest records first by using MAILED field. I came up with this query to pull the data: SELECT TOP 5 * INTO DESTINATON.dbf FROM SOURCE.dbf WHERE ZIP5 = '95003' ORDER BY MAILED ASC This query works. It select top 5 record, creates DESTINATON.dbf witch is identical in structure to SOURCE.dbf and populates it with selected records. The hard part is to update the MAILED field in the same query, so next time I don't use the same records. There in no unique field that i can use to match pulled records to the SOURCE.dbf and update it. I want to do it all in one shot, but I'm not sure that this is possible. I'm using ADO 2.7 Any help is greatly appreciated. Thank you Ilya :eek:

      J Offline
      J Offline
      Janya
      wrote on last edited by
      #2

      Try this with your appropriate primary key field name substitution. Not sure about your dbf suffix as it's been about 8 years since I touched dbase. SELECT TOP 5 SOURCE.* INTO DESTINATON FROM SOURCE LEFT JOIN DESTINATON on DESTINATON.PRIMARYKEY = SOURCE.PRIMARYKEY WHERE SOURCE.ZIP5 = '95003' AND DESTINATON.PRIMARYKEY IS NULL ORDER BY SOURCE.MAILED ASC Janya

      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