If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > ID update with various tables in a database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-07-10, 11:42
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
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.
Reply With Quote
  #2 (permalink)  
Old 01-07-10, 12:04
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
use the LAST_INSERT_ID function

it is explained quite adequately in da manual

you do have a mysql reference manual, yes?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-08-10, 09:37
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
No i am not having. Where i need to get it?
Reply With Quote
  #4 (permalink)  
Old 01-08-10, 10:31
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 01-09-10, 18:09
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
Hi, How about creating triggers in my case. Is that good?
Reply With Quote
  #6 (permalink)  
Old 01-09-10, 18:15
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by bharanidharanit View Post
Is that good?
depends on what you're trying to accomplish
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 01-09-10, 18:54
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
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?
Reply With Quote
  #8 (permalink)  
Old 01-09-10, 19:14
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by bharanidharanit View Post
How are they linking every tables?
here's a sample -- Flickr Photo Download: Facebook database schema
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 01-10-10, 08:46
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
Hey thankyou, that really helps me...
Reply With Quote
  #10 (permalink)  
Old 01-11-10, 08:26
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
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
Reply With Quote
  #11 (permalink)  
Old 01-11-10, 09:21
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by bharanidharanit View Post
Hi i want to get tbl_users.id
please see post #2 in this thread
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #12 (permalink)  
Old 01-11-10, 10:49
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
I referred that, but that one is little complex for me
Reply With Quote
  #13 (permalink)  
Old 01-11-10, 10:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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....
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #14 (permalink)  
Old 01-11-10, 10:57
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
I dint mentioned about LAST_INSERT_ID, but about da manual!!!
Reply With Quote
  #15 (permalink)  
Old 01-11-10, 11:08
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
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);
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On