Jump to content

How to make Table relation?


abdfahim

Recommended Posts

I am not sure whether it is possible what I m wanting to do. I have two table "tableA" and "tableB". Now I want 2 things ..

1) "columnA1" of "tableA" automatically contains same value as "columnB1" of "tableB". If I change/add anything in "columnB1" of "tableB", it will automatically changed/added in "columnA1" of "tableA".

2)I want "columnA2" of "tableA" = Sum of ("columnB2" of "tableB") all time. "columnB2" is a integer field.

So plz help me. I m very much starter in mysql.
Link to comment
https://forums.phpfreaks.com/topic/18168-how-to-make-table-relation/
Share on other sites

That is because I want to show the website summery (like total user, online user, post ... etc) on the 1st page of my website. To do this I have to access different database and tables which i afraid may coz delay in loading the page. So what I want is to create an extra table and put the necessary field related to original tables so that I can get all the info by accessing one single table.
Ok, the whole situation is -
I have 4 database "userdb","forumdb","newsdb","profiledb". [b]All databases are in the same server[/b], i.e. I have to connect once and then just switch database by the command "mysql_select_db()". All databases has seperate tables. Now I am afraid that switching databases 10/11 times in one page may increase the loading time of the page. So I create an extra table on "newsdb" database and trying to link this table with other table. The reason is given in my prev reply.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.