php - MySQL INNER JOIN with different column names -
okay, have 2 tables, news table , users table. set below:
news:
id title user_id contents users:
id username password when run query:
select news.title, users.username, news.contents news inner bring together users on news.user_id=users.id news.id=:id i can access user id using $query['id']. appears bring together using column names table2, although want them map column names of table1. though column called id in users table, want access under user_id, since specified in join query.
i need because if ever need id table1, both mapped column called id , able id of users table.
so there way this? access column table2 under name of column in table1?
in mysql specify in select statement called in result set, need tell give you. as command
select users.id user_id ... ... that way can phone call whatever want
or grab user_id news
select news.user_id ... ... php mysql pdo inner-join
No comments:
Post a Comment