Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:55:29+00:00 2026-06-11T10:55:29+00:00

I am from Python-Django background now i am doing my project in PHP. I

  • 0

I am from Python-Django background now i am doing my project in PHP.

I have three tables in 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    |                |
+-------+--------------+------+-----+---------+----------------+

At the time of user registration I am trying to store the tags for user. There can be more then one tags for a user.

So my question is how to write the SQL query so that my demo_user_selected_tags table also has a value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:55:30+00:00Added an answer on June 11, 2026 at 10:55 am

    You should use some ORM like Doctrine for example.

    With Doctrine You define the table models and their relations with all the primary and foreign keys. After that it is enough to create an object of User, set its properties and tags and just save this User object – Doctrine will do the work for You and will fill the apropriate IDs (values) into all the related tables…

    In other words, imagine we have a User object, that has many-to-many relation with Tags… We set some tags for this User and then save the User:

    $user = new UserModel();
    $user->name = 'some name';
    $user->email = 'some@email.com';
    foreach($tags as $id => $tag)
        $user->tags[$id] = $tag; // in model definition the tags property is a many-to-many relation for Tags table...
    $user->save(); // and the work is done...
    

    This is just an example on how this work could be done…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm from a PHP background but have been given a Django project to administer,
I'm moving from a PHP background into Django development via python, mostly for the
I have been coding in python/django and c/c++ from last three years for various
I'm a complete n00b to django & python. I come from a PHP background
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
I have a MySQL stored procedure that is executed from Python (wrapped in Django).
I'm a developer in Python coming from a PHP background. In PHP most frameworks
I am of the PHP background and just have started to learn Django and
Background: I'm starting off with Django, and have limited experience with Python, so please
I have a Python (Django) unit test FAIL from an exception, but the failing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.