Results 1 to 5 of 5

Thread: Creating a linked list of results?

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Creating a linked list of results?

    I have a table with metadata in it that I need to present two separate but related lists for.

    Code:
    Table1
    -----
    id  |  value  
    1   |  Employee_Edited  
    2   |  Employee_Created  
    3   |  Employee_Deleted
    4   |  Manager_Hired
    5   |  Manager_Fired
    Now I have used sql functions to parse "Employee_Edited" into "Employee", "Edited":


    Code:
    sql query results
    -----------
    id  |  value  |  valueOnly  |  actionOnly
    1   |  Employee_Edited  |  Employee  |  Edited
    2   |  Employee_Created  |  Employee  |  Created
    3   |  Employee_Deleted  |  Employee  |  Deleted
    4   |  Manager_Hired  | Manager  |  Hired
    5   |  Manager_Fired  |  Manager  |  Fired
    Now I figured I could add a Distinct query and have just the "Employee" in a list but at some point I need to display the list on the webpage with each associated action. Note not all values will have the same actions.


    Results 1
    -----------
    Employee
    Manager

    Then when the user selects Manager the second list will propagate to display:
    Results 2
    ----------
    Hired
    Fired


    I don't want to have a second db call as that would be the obvious way to solve this but not the best for performance imo.
    Whats the best way to write the query for this? Using SQL and JavaScript on an MVC website

    Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Frenzied Member
    Join Date
    Jun 2014
    Posts
    1,084

    Question Re: Creating a linked list of results?

    Code:
    Table1
    ------
    value    | action
    -------------------
    Employee | Edited
    Employee | Created
    Employee | Deleted
    Manager  | Hired
    Manager  | Fired
    PK=value & action
    do not put off till tomorrow what you can put off forever

  3. #3

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Creating a linked list of results?

    Thanks but that's the problem. I need 2 queries out of it to produce non repeating information. Employee will have 3 pk's (id's) but I want in one list just Employee so when selected I can filter by Employee I guess as cant filter by the id since it may be one of 3 to get its associated action
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Creating a linked list of results?

    Hi,

    dont now if it's this your after

    I tested this with Access with the Northwind DB
    Code:
    SELECT DISTINCT Customers.CompanyName, Customers.City, Customers.Country
    FROM Customers
    WHERE (((InParam([ContactTitle],[Type Owner,Sales Agent,Sales Manager]))=True));
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  5. #5
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Creating a linked list of results?

    not sure I understand the question? you say you've already got the sql?

    That one query result you've shown is enough to display:

    Employee
    +-- Edited
    +-- Created
    +-- Deleted
    Manager
    +-- Hired
    +-- Fired

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width