You can set aliases for the columns that you are selecting:
$query = 'SELECT news.id AS newsId, user.id AS userId, [OTHER FIELDS HERE] FROM news JOIN users ON news.user = user.id'
More Related Contents:
- Order results from two queries based on time in second query [closed]
- Query database then email posts from where user is subbed to
- Using PHP data in MySQL [closed]
- Checking the availability of rooms
- How can I do ‘insert if not exists’ in MySQL?
- Can I parameterize the table name in a prepared statement?
- How to properly set up a PDO connection
- Getting raw SQL query string from PDO prepared statements
- Correct way to use LIKE ‘%{$var}%’ with prepared statements?
- MySQL Prepared statements with a variable size variable list
- PDO with INSERT INTO through prepared statements [closed]
- How to search for slash (\) in MySQL? and why escaping (\) not required for where (=) but for Like is required?
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102 [closed]
- Comma separated values in MySQL “IN” clause
- SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax — PHP — PDO [duplicate]
- Doing a while / loop to get 10 random results
- PHP – Import CSV file to mysql database Using LOAD DATA INFILE
- MYSQL Select from tables based on multiple rows
- How to execute raw queries with Laravel 5.1?
- Simple PHP SQL login troubleshooting
- Change date format (in DB or output) to dd/mm/yyyy – PHP MySQL
- How do you do multiple SQL statements in one mysql_query?
- MySql PHP select count of distinct values from comma separated data (tags)
- Laravel Eloquent get results grouped by days
- MySQL/SQL retrieve first 40 characters of a text field?
- Do I have to use mysql_real_escape_string if I bind parameters?
- SELECT row by DATEPART()
- UNION syntax in Cakephp
- How do i search from serialize field in mysql database?
- PDO and MySQL ‘between’