Get auto increment id of two linked tables (INNER JOIN)

-1

Let's see if I can explain at first ...

I have two tables [topics] and [notification]

I joined these tables with INNER JOIN to get the data of both, so far so good ...

But when I need to select the [id] from the [notification] table in the while, but only returns the [id] of the table [topics], how can I retrieve the id of both in that select?

Here's my SELECT:

SELECT notification.*, topicos.* FROM notification INNER JOIN topicos ON notification.user = "USUARIO_TAL" 
    
asked by anonymous 18.08.2018 / 03:17

1 answer

1

Ideally, you should list the columns that interest one by one, instead of using * . Then you can set an alias for each one if necessary. For example:

SELECT
    notification.id AS notification_id,
    topicos.id AS topico_id
...

In your while (in php, from what you said), you can refer to the id by alias, in the case notification_id or topico_id .

    
18.08.2018 / 03:20