Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

SQL - Best way to do this?

  • 12-03-2008 10:36AM
    #1
    Closed Accounts Posts: 5,240 ✭✭✭


    I have 3 tables - Events, People, PTypes.

    Events has a PeopleID field, the PeopleID comes from the People table. The People has a PTYPEID field, this PTYPEID comes from the PTypes table.

    There are three different PTypes, 1- Staff, 2- Visitor, 3- Inmate. These descriptions are held in PTypes under a description field, and referenced as 1, 2 or 3 around the database as PTYPEID.
    I need my report to be able to print out either Staff, Visitor or Inmate depending on which the Person is, just not sure how to link all the data together :confused:

    My SQL so far looks like this:
    SELECT e.EventTypeID, EventTime, e.Description, e.PeopleID, e.EventID,(p.Forename + ' ' + p.Surname) AS UserName, (p.PTYPEID) as Operator 
    FROM Events e
    LEFT OUTER JOIN eventtypes t on e.EventTypeID = t.EventTypeID 
    LEFT OUTER JOIN people p on p.PeopleID = e.PeopleID
    WHERE (e.eventtypeid > 3000) and (e.eventtypeid < 4000)
    

    That only prints the number, 1/2/3, how could i access the Description of the PTYPE?

    Cheers
    Endo


Comments

  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    how could i access the Description of the PTYPE?

    By joining to the PType table...


Advertisement