'Tags' on an object
Results 1 to 2 of 2

Thread: 'Tags' on an object

  1. #1
    Senior Member
    Join Date
    Apr 2005

    'Tags' on an object

    I'm looking at a file upload script at the moment.

    I want 2 options that'll operate in the same way, I want it to link to multiple people. So for example

    My Photos database will have a row, PhotoID, PhotoURL etc etc.

    I have a people table, I want to link unlimited number of ID's to this photo. What is the best way?

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Add a people-to-photo table, where the 2 columns are the primary keys of the two related tables. You might end up with a query something like this:
      GROUP_CONCAT(user.name) AS tagged_users
    FROM photo
    LEFT JOIN user_to_photo AS u2p ON u2p.photo_id = photo.id
    LEFT JOIN user ON u2p.user_id = user.id
    WHERE photo.id = 123;
    GROUP BY photo.path, photo.title -- might not need this line in MySQL?
    tagged_users will then be a comma-separated list of user names.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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