How do I add a one-to-one relationship in MYSQL?
Posted
by alex
on Stack Overflow
See other posts from Stack Overflow
or by alex
Published on 2010-04-27T20:11:50Z
Indexed on
2010/04/27
20:13 UTC
Read the original article
Hit count: 283
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| pid | varchar(99) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)
+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| pid | varchar(2000) | YES | | NULL | |
| recid | varchar(2000) | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
This is my table. pid is just the id of the user. "recid" is a recommended song for that user.
I hope to have a list of pid's, and then recommended songs for each person. Of course, in my 2nd table, (pid, recid) would be unique key.
How do I do a one-to-one query for this ?
© Stack Overflow or respective owner