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?
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.