Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 table and i want to pull data from both of them. This is sample for my table structure:

Table tbl_a = id, time, note, customer Table tbl_b = id, time, name, surname, note

This is my mysql request:

Select * from tbl_a left join tbl_b on tbl_a.customer=tbl.b=id where;

When i run this query directly from mysql i can see result exactly as i want but i dont know how to display it in my php page.

i am doing it like this:

$sql = mysql_query("Select * from tbl_a left join tbl_b on tbl_a.customer=tbl.b=id where");
$data = mysql_fetch_array($sql);

echo $data[id]." - ".$data[time]." - ".$data[note]." - ".$data[customer]." - ".$data[id]." - ".$data[name]." - ".$data[surname]." - ".$data[note];

i know that column names that are repeated could not be used again but i dont know what the right way is.

share|improve this question
up vote 0 down vote accepted

I suggest instead of using the ALL (*). just type the column names with an AS attached such as: AS TableAId, AS TableBId and so on.

share|improve this answer
Thank you a lot. is there any quicker way to do that becouse i have about 40 column? if not i will use your suggestion – mandza Nov 22 '13 at 12:35
Not that I know of. hopefully someone can shed some light if there's a way. – user2558461 Nov 22 '13 at 13:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.