table entries, query construction
| From: | Russ Michell | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | table entries, query construction | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-12560@lists.php.net to get a copy of this message | ||
Hi all:
As it stands I have a users table with several fields of personal details and a
single field representing a user's affiliated sports-team.
I also have a separate table that consists of these sport-teams.
The problem is that I'd like each user to be able to sign up for more than one team,
i.e.: for multiple teams to be listed in the team field.
However the entire system relies on the fact that users can be identified
by which sport-teams they are affiliated with and appropriate
page content is delivered on this basis.
How can I fill the users' team-affiliation field with multiple entries,
and still be able to map these as individual entities to scripts/SQL queries that deliver content
on the basis of single team affiliation?
I thought about a comma-separated list of sport-teams within the table field,
but how would I construct the query to display appropriate username/sport-team content?
//A possibility?
SELECT affil_team FROM $table_users WHERE usrName='$username' AND
affiliation='one_of_the_comma_separated_values";
Would the 'LIKE' clause do the job here?
Does anyone have any ideas over and above my own, on how I may be able to go on with this?
Many thanks.
Russ
#-------------------------------------------------------#
"Believe nothing - consider everything"
Russ Michell
Anglia Polytechnic University Webteam
Room 1C 'The Eastings' East Road, Cambridge
e: r.j.michell@apu.ac.uk
w: www.apu.ac.uk/webteam
t: +44 (0)1223 363271 x 2331
www.theruss.com
#-------------------------------------------------------#