Results 1 to 4 of 4
  1. #1
    dollygg is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    73

    use cursor or subquery?

    Table A:



    Site columnB

    1087242 abc
    1091220 asd
    1094730 qwe

    Table B:

    site phone phonetype phonestring
    1087242 754369 Company (888) 123-0354
    1087242 754370 CompanyFax (800) 123-9506
    1091220 759259 Company 1-888-123-0354
    1091220 759260 CompanyFax 1-800-123-9506
    1094730 763115 Company (1 888) 123-0354
    1094730 763116 CompanyFax (1 800) 123-9506
    1098525 767232 Company 1-888-123-0354
    1098525 767233 CompanyFax 1-800-123-9506


    result wanted:

    site columnB phonenumber faxnumber
    1087242 abc (888) 123-0354 (800) 123-9506

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Try a CROSSTAB query:

    1. build a query A with the data you want to use
    2. Then use the QUERY WIZARD, and select CROSSTAB query
    3. use query A from step 1, tell it how you want to view the data (it will ask)

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Neither; join table b to table a twice. See if this gives you an idea, from something I'm working on where I needed to denormalize data in a locations table (note this is from SQL Server, Access syntax may differ slightly):

    Code:
    SELECT PU.FieldName As PickupLocation, DO.FieldName as DropoffLocation
    FROM ResSegments Seg
    
      --SC splits the pickup and dropoff addresses into a related table, these allow denormalization
      --type 0 is pickup, type 1 is dropoff, type 2 is for stops, not used here
      LEFT JOIN ResSegmentLocations PU 
        ON Seg.SegmentRowId = PU.SegmentRowId And PU.LocationPhaseType = 0 
      LEFT JOIN ResSegmentLocations DO 
        ON Seg.SegmentRowId = DO.SegmentRowId And DO.LocationPhaseType = 1
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Geez, am I a slow typist or what?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Changing the cursor
    By BernardKane in forum Forms
    Replies: 4
    Last Post: 10-24-2022, 09:59 AM
  2. Cursor in Forms after validation
    By pervezjan in forum Access
    Replies: 5
    Last Post: 06-22-2014, 12:07 AM
  3. Open pop up form at cursor.
    By ser01 in forum Forms
    Replies: 5
    Last Post: 08-06-2013, 11:09 AM
  4. Replies: 2
    Last Post: 02-17-2012, 04:09 AM
  5. T-SQL Cursor within a cursor
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 6
    Last Post: 04-14-2011, 12:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums