Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2010
    Posts
    10

    Question Conditional query in access 2003

    Hi all !


    I have a access 2003 DB with one table, for ex. which contains the info about the users and their PCs like this:
    | name | PC1 | PC2 | PC3 |
    | Jack |Asus |Lenovo| HP |
    |John | DELL | | |
    |Anna | |Asus | |

    Now I need a sql query code that return this info but distincted, like this:

    | name | PC |
    | Jack | Asus |
    | |Lenovo|
    | | HP |
    |John | DELL |
    |Anna | Asus |

    or in the bad case like this:

    | name | PC |
    | Jack | Asus |
    | Jack |Lenovo|
    | Jack | HP |
    |John | DELL |
    |Anna | Asus |

    Can anyone help me to do that ?
    Please !!!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Hopefully you're fixing the original design, which is flawed. You can use a UNION query:

    SELECT Name, PC1
    FROM TableName
    WHERE PC1 Is Not Null
    UNION ALL
    SELECT Name, PC2
    FROM TableName
    WHERE PC2 Is Not Null
    ...

    That will repeat the name, but you can get the look you want on a report.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    Nov 2010
    Posts
    10

    Thumbs up

    My idea was to create separated queries for each PC and then to concatenate its. But your idea and solution are better.

    Thank you very much pbaldy !

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help, and welcome to the site by the way!
    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. Help with Conditional statement in query
    By Rhues in forum Queries
    Replies: 1
    Last Post: 01-11-2010, 02:09 PM
  2. Conditional Query Question
    By Silver Rain 007 in forum Queries
    Replies: 0
    Last Post: 11-16-2009, 11:30 AM
  3. Access 2003 Query Help?
    By Stirling Steve in forum Queries
    Replies: 1
    Last Post: 08-26-2009, 03:25 AM
  4. Replies: 1
    Last Post: 09-06-2006, 11:48 AM
  5. Conditional Format Query
    By Schwagr in forum Queries
    Replies: 3
    Last Post: 03-20-2006, 02:39 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