我是從Python-Django背景現在我正在做我的項目在PHP中。Mysql:保存數據在許多領域
我有三個表在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 | |
+---------+---------+------+-----+---------+----------------+
demo_user
+--------------------+---------------+------+-----+---------+----------------+
| 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 | |
+--------------------+---------------+------+-----+---------+----------------+
demo_tags
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| tags | varchar(150) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
在用戶註冊時,我試圖爲用戶存儲標籤。用戶可以有多個標籤。
所以我的問題是如何編寫SQL查詢,以便我的demo_user_selected_tags
表也有一個值?
也許'INSERT INTO'?對不起,但我沒有關注... – Gerep
你在尋找插入腳本嗎? – sundar
是啊我只是想找到那隻 – user1614526