SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automatically insert

    Hi guys,

    I have 2 tables related to users:
    'users' this contains all the commonly used information like username, password, etc.
    'user_details' which contains other details like location, dob, forename, etc.

    What I want to happen is when a user registers and has their details inserted into users a record is automatically created within user_details.

    Is this possible without having to create a separate queries for the user table and user_details table?

    Thanks.

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, by using a trigger.
    Look there for examples and explanation on how to use them
    http://dev.mysql.com/doc/refman/5.0/...e-trigger.html

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    will there ever be more than one row in user_details for each row in users?

    if not, they should be combined, and then you don't need to do anything

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    455
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tripy View Post
    Yes, by using a trigger.
    Look there for examples and explanation on how to use them
    http://dev.mysql.com/doc/refman/5.0/...e-trigger.html
    Thank you for the link.

    Quote Originally Posted by r937 View Post
    will there ever be more than one row in user_details for each row in users?

    if not, they should be combined, and then you don't need to do anything

    There will only be one row for each user, so I will combine them.



    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •