我来自 Python-Django 背景,现在我正在用 PHP 做我的项目。
我在 MySQL 中有三个表:
demo_user_selected_tags
+---------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | MUL | NULL | |
| tags_id | int(11) | NO | MUL | NULL | |
+---------+---------+------+-----+---------+----------------+
演示用户
+--------------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_name | varchar(100) | NO | | NULL | |
| first_name | varchar(100) | NO | | NULL | |
| middle_name | varchar(100) | NO | | NULL | |
| last_name | varchar(100) | NO | | NULL | |
| image | varchar(5000) | YES | | NULL | |
| password | varchar(80) | NO | | NULL | |
| role | varchar(20) | NO | | NULL | |
| org_name_id | int(11) | NO | MUL | NULL | |
| timezone_id | int(11) | NO | MUL | NULL | |
| city | varchar(50) | YES | | NULL | |
| state | varchar(50) | YES | | NULL | |
| country | varchar(50) | YES | | NULL | |
| street | longtext | YES | | NULL | |
| pin | varchar(30) | YES | | NULL | |
| user_type | varchar(30) | NO | | NULL | |
| status | int(11) | YES | | NULL | |
| primary_mobile | varchar(100) | YES | | NULL | |
| secondary_mobile | varchar(100) | YES | | NULL | |
| primary_landline | varchar(100) | YES | | NULL | |
| secondary_landline | varchar(20) | YES | | NULL | |
| primary_email | varchar(100) | YES | | NULL | |
| secondary_email | varchar(100) | YES | | NULL | |
| notes | longtext | NO | | NULL | |
| date_created | datetime | YES | | NULL | |
| date_modified | datetime | YES | | NULL | |
+--------------------+---------------+------+-----+---------+----------------+
演示标签
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| tags | varchar(150) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
在用户注册时,我正在尝试为用户存储标签。一个用户可以有多个标签。
所以我的问题是如何编写 SQL 查询,以便我的demo_user_selected_tags
表也有一个值?