Reputation: 229
i made this query that interacts with two tables but i have a problem fetching the data since both tables share the same field names.
SELECT * FROM `data` d JOIN `ans` a ON d.id=a.id AND d.id=2987
the result is:
id nick msg time ip time_updated id nick msg time ip
how can i make it to look like this?
a.id a.nick a.msg a.time a.ip a.time_updated b.id b.nick b.msg b.time b.ip
Upvotes: 1
Views: 572
Reputation: 180004
You'll have to name each field specifically to do this.
SELECT a.id AS 'a.id', a.nick AS 'a.nick', ... FROM `data` d JOIN `ans` a ON d.id=a.id AND d.id=2987
Upvotes: 4
Reputation: 8996
you need to give alias also to fields:
SELECT a.id AS a_id, b.id AS b_id ....
Upvotes: 3