Jump to content

how to reference another table while using UPDATE


sid0972

Recommended Posts

i am working on a website,on mysql and php.

 

i have two tables,

 

table 1 table 2

 

username pri_key username pri_key

field_1 field_3

field_2 field_4

 

i want to update ( if not, then insert) values in table 2, all the values, referencing table 1.

 

Like "update table 2 set username='this', field_3='....' and field_4='...' where username{from php as session variable}='name referenced from table 1';

 

I was wondering what would be the query for this.

Link to comment
Share on other sites

cause these are the columns that will be users posts, updated regularly.

I have solved the problem, the 2ndt table gets updated with username automatically when an entry in 1st table is made.

 

On a side note, does anyone have a better table structure for this purpose??

Link to comment
Share on other sites

it is a member profile system, similar to bulletin boards, forums, like this one itself (phpfreaks), with much less functionality.

 

I was asking about this do that i could store their posts in another table, and could retrieve posts according to user names and post id's.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.