PHP & MySQL - Identify table in results from joined tables -


say have following query:

$sql = "select * cars left join trucks cars.user_id=$user_id , trucks.user_id=$user_id"; 

since page cars , trucks have different layouts how know result belongs table ? same different table names.

how retrieve table names ?

thanks in advance

all columns on left belong left table i.e. cars , right truck.

so e.g. if have table cars(id..) , truck(id..)

then output be

id...(from cars) id..(from truck) 

if want specific columns use like:

select `truck`.id,`cars`.id... 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -