Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Nov 2008
    Posts
    117

    Unanswered: ID update with various tables in a database

    Hello,
    I am using login table and user table. When i add some datas in login table, that corresponding ID(Autonumber field) from login table must be updated with user table.
    How to perform this? This must handles for very large number of users.
    Thankyou.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use the LAST_INSERT_ID function

    it is explained quite adequately in da manual

    you do have a mysql reference manual, yes?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2008
    Posts
    117
    No i am not having. Where i need to get it?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bharanidharanit View Post
    No i am not having. Where i need to get it?
    MySQL :: MySQL Documentation

    available in several languages
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2008
    Posts
    117
    Hi, How about creating triggers in my case. Is that good?

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bharanidharanit View Post
    Is that good?
    depends on what you're trying to accomplish
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Nov 2008
    Posts
    117
    Quote Originally Posted by r937 View Post
    depends on what you're trying to accomplish
    Again in a social networking website, they have profile pages, scrapbook, friendlist, photos etc. This must be different among every users. They must have different tables. How are they linking every tables? If mostly by id, how to link every tables, after a user registration?

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bharanidharanit View Post
    How are they linking every tables?
    here's a sample -- Flickr Photo Download: Facebook database schema
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Nov 2008
    Posts
    117
    Hey thankyou, that really helps me...

  10. #10
    Join Date
    Nov 2008
    Posts
    117
    Hi,
    i am having tbl_users and tbl_profile tables. After a new record created in tbl_users, i want to get tbl_users.id and insert that id in a profile table. I used this coding, but i know how to retrieve id from tbl_users to a tbl_profile table?
    Here's my coding,
    Code:
    use db_snw;
    create trigger update_id
    after update on tbl_users
    for each row begin
    
    end

  11. #11
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bharanidharanit View Post
    Hi i want to get tbl_users.id
    please see post #2 in this thread
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  12. #12
    Join Date
    Nov 2008
    Posts
    117
    I referred that, but that one is little complex for me

  13. #13
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by bharanidharanit View Post
    I referred that, but that one is little complex for me
    LAST_INSERT_ID is "too complex" for you? and yet you're trying to write a trigger?

    something about this doesn't smell right....
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  14. #14
    Join Date
    Nov 2008
    Posts
    117
    I dint mentioned about LAST_INSERT_ID, but about da manual!!!

  15. #15
    Join Date
    Nov 2008
    Posts
    117
    Hello,
    Do you mean this? This is returning all the values from the insert table.
    Code:
    select * from tbl_users where id=last_insert_id(id);

Posting Permissions

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