My scripts are doing a lookup of transactions in table B. Each transaction contains an integer which is an ID of the business for each transaction. I also want the name (a varchar) of the business in the original transaction. My solution was to do a 2nd lookup for each transaction record and this works, but I would like to be able to sort the 1st transaction by the business name. I suspect the answer is to do a left-join transaction and get the name from that. However, I've never mastered left join and even though I looked it up again, I'm still not sure how it works. So, let me give an example of how I'm doing it now and maybe someone can suggest a better way.

$queryString = select * from tableB;//(truth be told, table B is called 'trips')
$result = mysqli....
 $queryString2 = select bizname from tableA where ID = $array[ID]//(tableA is called 'companies')

Any help would be appreciated.
Jeff Sandler

While I don't claim to solve this I always cringe when I see the "select *" in any query. There are a lot of articles why you always check for this and I don't know the table structure so I can't guess if you need all in the result set. Do you?

I've fixed many SQL speed problems on this alone. Worth checking.

select a.bizname, b.col1, b.col2, b.col3 from table a, tableB where a.ID = b.ID;
I don't thinks an outer join is needed, and it's true a select * is a bad ...

It's annoying when people ask a straight up SQL question and wrap everything in $LANGUAGE.

To cut a long story short, what you need is a join.