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
Post a Comment