Working with two lots of columns using INNER JOIN

I am using the following query to select wait times from the table wait_times where the user id is 1 and then select the venue's information that has the id of the wait time's venue id.

SELECT w . * , v . *
FROM  `wait_times` AS  `w` 
INNER JOIN  `venues` AS  `v` ON  `v`.id =  `w`.venue_id
WHERE w.user_id =1
LIMIT 0 , 30

However, when I perform this query, as I have columns named user_id and id in both tables, I received two lots of values for each column name. Please can you tell me how I make these values distinguishable, and rename them to 'table_name.columnname' respectively so that they can be easily recognised?

Answers


One solution would be:

SELECT w.colum1 as name1, w.colum2 as name2, w.*, v.colum1 as name3, v.colum2 as name4, v.*
FROM  `wait_times` AS  `w` 
INNER JOIN  `venues` AS  `v` ON  `v`.id =  `w`.venue_id
WHERE w.user_id =1
LIMIT 0 , 30

Just allocate the colums which have the same name a (temporary) different name.


Need Your Help

What are unit tests and why should I care?

php javascript unit-testing

Okay, I develop web applications in PHP and JavaScript and a lot of times here on Stack Overflow I have seen the word unit test passing by, but nowhere on the website have I been able to found a

Howto detect in Docker the container kernel version

centos docker

The application stack I want to dockerize shall run within a CentOS container. The installation procedure verifies kernel version to ensure application requirements are met. Currently it is detected