Columns with equal names in a single query, mysql

3

I'm running a MySQL query in this style:

select contents.*, users.* FROM users, contents

In both tables there are columns with the same name, and at the time of pulling them with PHP it is the first one, but I want both.

Is there any way to get both data from these columns without having to change each column name? I thought I'd put a prefix on it, something like that, but I do not know if it's functional.

    
asked by anonymous 12.09.2016 / 16:00

1 answer

7

You can do this:

select contents.nome_igual as nome1, users.nome_igual as nome2 FROM users, contents
    
12.09.2016 / 16:06