1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Query Separating Value from a single column in database

Discussion in 'Programming' started by kimimaro, Feb 4, 2009.

  1. #1
    Hello as the title stated... I have a column "name" in "meeting" table which contains names such as Mark,Henry,Bobby and it must remain so (All names separated with a comma in the "name" column instead of having each record for each name)

    I have another table which is the staff profile whereas each staff have their own unique record with the PK name(Assuming all the names of the staffs are unique)

    I dont want to have each staff separated in the "meeting" table is because i wanted to group all of them to easily displayed grouped by the meeting table's id


    Now my question is how do i query to display or uniquely separate the name from the meeting table?


    I tried



    SELECT *
    FROM meeting m, staff s
    WHERE s.name IN
    (
    m.staff
    )



    and






    SELECT *
    FROM meeting m, staff s
    WHERE s.name IN
    (
    <cfqueryparam value="#m.staff#" list="yes">
    )



    Both not working :confused:
     
    kimimaro, Feb 4, 2009 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ouch! Do yourself a favor and do not store them in a single column. It is a bad structure and it is the reason you are struggling with this query. If the values were stored in a separate table (one record per name) your query would be much simpler. That is not even mentioning the problems you will have if a name changes in one table, but not the other.

    You should not design a database around how the information will be displayed. If your table were designed properly, you could easily group the staff by meeting id using cfoutput with "group". A better layout would be:

    [Meetings table]
    MeetingID, Title
    1, Meeting A
    2, Meeting B
    ...

    [StaffMeetings table]
    MeetingID, StaffID
    1, 1 (Mark)
    1, 3 (Henry)
    1, 6 (Bob)
    ...
     
    cfStarlight, Feb 5, 2009 IP