How to create a column in a table from a Select

0

I have the users table and the posts table, I need to copy the same information from a users table column to a posts table column. For example, I have this code:

SELECT posts.*, users.username
FROM posts
  inner join users on (posts.user_id = users.id )

I want to be able to see what I need, but in my project in php I need this column to be created, so I can see it through my html.

One more example to help in understanding my question, if I run the code:

ALTER TABLE articles ADD COLUMN user_id INT(11);

It can create exactly what I need, but with the "id" field that is in the users table, but only with the id , if I do the same code with the field I need, which is the username : "user_username", returns me null.

    
asked by anonymous 25.11.2015 / 19:48

0 answers