We Talk Coding

Linking tables in two MySQL databases?

Hi, I have two MySQL databases, one forum and one directory and I need some help on how to link the Username and Password tables between the databases so that a person can sign up on database 1 and it automatically updates database 2 so they can login with the same details. Any help would be much appreciated. I've now created one database from the two but I still have two seperate tables feeding to the two programs, I'm quite new to MySQL so this is prob easy to do! I have table 1 called "dir_editors" with the fields "username" and "password" this is the table the data would be entered into. I then need this to pull automatically into table 2 called "pp_users" with the fields "username" and "user_password". So the data from table 1 username feeds to table 2 username etc. Please help I'm going nuts!!!

Public Comments

  1. You can use join statement.
  2. You should really only keep one table so that users aren't duplicated. I would export the user data from table1 and import it into table2, then just use the combined table. BUT, if you want to stick with 2 tables... Do 2 inserts/updates whenever you change user information. INSERT INTO table1 (user, pass, ...) VALUES (x, y, ...) INSERT INTO table2 (user, pass, ...) VALUES (x, y, ...) and your authentication would be something like: SELECT * FROM table1 a, table2 b WHERE a.user = 'username' AND a.pass = 'password' AND b.user = 'username' AND b.pass = 'password'
  3. using Access, just go to design your User table.. under the property of the table, select no duplicate for the particular.. then u can go to relational model there to link your table.. hope it help..
  4. Hi, Have one table to hold the username and password. This can contain a key (which could be the natural key like the username, if you make it unique) which you would use to link to a second table which stores what databases/tables/webpages etc etc that user has access to. You could set up your code so that both tables are updated initially with the same information. You would also be able to edit this later. You could then take this concept further, and have a another table which is updated with a single entry everytime a user logs in. This table would just contain your username and a dateTime. Handy if you want to track usage. You might find it worthwhile tracking down some free SQL guides of the web regarding simple database design - try looking at normalisation and joins. I don't know the specifics on mysql, but SQL syntax is fairly uniform across databases with the exception of some database specific keywords and join syntax. Good luck
Powered by Yahoo! Answers