Results 1 to 7 of 7
  1. #1
    wittybrent is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2013
    Posts
    5

    Convert row with columns of data into multiple rows?

    I have two tables...

    TABLE A:
    Click image for larger version. 

Name:	Table A.jpg 
Views:	7 
Size:	51.5 KB 
ID:	12282

    TABLE B:
    Click image for larger version. 

Name:	Table B.jpg 
Views:	8 
Size:	108.6 KB 
ID:	12283

    I will display the following values in report or in result table in query:

    StudentNumber: 131003
    Name: MABAG, MANUEL B.

    Subject Unit Days Time Room


    AB1AA-ENG 101 3
    AB1AA-COMP 101 3
    ...

    Thank you for the help???

  2. #2
    wittybrent is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2013
    Posts
    5

    Can I use the PIVOT code in this example?

    I have the following table:

    TABLE A:
    StudentNumber Subject1 Subject2
    11111 AAA BBB
    22222 AAA BBB

    how will i display the multiple values in row into one column?
    RESULT TABLE:
    StudentNumber Subject
    11111 AAA
    11111 BBB
    22222 AAA
    33333 BBBB

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This requires a UNION query. There is no wizard for UNION. Must type (or copy/paste) in the SQL View of query designer. This will essentially rearrange the data into the structure it should have been in.

    SELECT StudentNumber, Subject1 AS Subjects FROM Registration
    UNION SELECT StudentNumber, Subject2 AS Subjects FROM Registration;

    Then join the UNION query to the SubjectSched table.
    Last edited by June7; 05-09-2013 at 10:10 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    wittybrent is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2013
    Posts
    5
    thanks for the help... appreciate so much... i tried the UNION but i used INNER JOIN... thanks again...

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Ooops! I forgot to use UNION in my query example. Take another look at the corrected post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    wittybrent is offline Novice
    Windows 8 Access 2007
    Join Date
    May 2013
    Posts
    5
    Thank you... June7... it helps me a lot... I figure out other query codes by using INNER JOIN....

    here is my code,, it works already... thank you...

    SELECT StudentNumber, LastName & ", " & FirstName & " " & MI AS NAME, Section, SectionSubjectCode, Unit, Days, Time, Room
    FROM SubjectSched INNER JOIN Registration ON Registration.Subject1=SubjectSched.SectionSubjectC ode Or Registration.Subject2=SubjectSched.SectionSubjectC ode Or Registration.Subject3=SubjectSched.SectionSubjectC ode Or Registration.Subject4=SubjectSched.SectionSubjectC ode Or Registration.Subject5=SubjectSched.SectionSubjectC ode Or Registration.Subject6=SubjectSched.SectionSubjectC ode Or Registration.Subject7=SubjectSched.SectionSubjectC ode Or Registration.Subject8=SubjectSched.SectionSubjectC ode Or Registration.Subject9=SubjectSched.SectionSubjectC ode;


    thank you po...

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I have never seen a join clause like that. I never would have considered it and don't understand how it can work but if you are getting what you want then congratulations.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Display multiple rows into seperate columns
    By levinkev in forum Queries
    Replies: 1
    Last Post: 08-30-2012, 11:02 AM
  2. Replies: 1
    Last Post: 05-14-2012, 04:12 AM
  3. Convert multiple rows to columns?
    By NelsonKauley in forum Programming
    Replies: 2
    Last Post: 04-04-2012, 04:59 PM
  4. Replies: 2
    Last Post: 01-02-2012, 06:46 PM
  5. Unmatched with multiple columns and rows
    By sampson20 in forum Programming
    Replies: 1
    Last Post: 04-18-2011, 10:48 AM

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