php - MySQL INNER JOIN with different column names -


OK, so I have two tables, a news table and a user The table is installed as the following:

News:

  ID title user_id content  

User: / P>

  ID Username Password  

When I run this query:

  Select News Join news newsletters from YouTube, users.username, news.contents ON news.user_id = users.id WHERE news.id =: ID  

I only $ query [' Id]] to access the User ID So it appears that the insert is using column names from table 2, although I want to map them to column 1 column names. So although the column is called in the user table named id , I want to access it under user_id , because I have specified that JOIN query

I need this because if I ever need id then from table 1, they will both be mapped to the id column and I Only able to get the id of the user table

What is the way to do this? Enter column 2 in column 2 under column name in Table 1?

In MySQL, how do you specify the selection statement is that which is said in the result set, so You should tell what you have to give. You do this

  SELECT users.id as user_id ... by ...  

In this way you can call it as you want < User_d from the news with

or

  SELECT news.user_id ... to <...  
Hold on.

Comments