database - How do I add a one-to-one relationship in MYSQL? -


+-------+-------------+------+-----+---------+-------+ | field | type        | null | key | default | | +-------+-------------+------+-----+---------+-------+ | pid   | varchar(99) | yes  |     | null    |       | +-------+-------------+------+-----+---------+-------+ 1 row in set (0.00 sec)   +-------+---------------+------+-----+---------+-------+ | field | type          | null | key | default | | +-------+---------------+------+-----+---------+-------+ | pid   | varchar(2000) | yes  |     | null    |       | | recid | varchar(2000) | yes  |     | null    |       | +-------+---------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) 

this table. pid id of user. "recid" recommended song user.

i hope have list of pid's, , recommended songs each person. of course, in 2nd table, (pid, recid) unique key.

how do one-to-one query ?

# retrieve songs associated given user     select songs.* user inner join songs on (user.pid = songs.pid) user.pid = ? 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -