using joins
Posted: Sun Aug 07, 2005 11:40 am
Hi all,
I have only recently begun looking at joins as an optimization method for some of my code. I would like to pull data from two tables into one result set. However, instead of listing each column that I would like to pull from both tables I wonder if there is a way to get all columns from one table and a select few from another.
ie
"SELECT table1.*, table2.id, table2.f_name, table2.l_name FROM table1, table2 WHERE table1.root_id=".$cid." AND table1.poster_id=table2.id"
essentially I am searching table 1 for any threads posted in a particular category and I would like to pull the username and id from the second table only.
I have only recently begun looking at joins as an optimization method for some of my code. I would like to pull data from two tables into one result set. However, instead of listing each column that I would like to pull from both tables I wonder if there is a way to get all columns from one table and a select few from another.
ie
"SELECT table1.*, table2.id, table2.f_name, table2.l_name FROM table1, table2 WHERE table1.root_id=".$cid." AND table1.poster_id=table2.id"
essentially I am searching table 1 for any threads posted in a particular category and I would like to pull the username and id from the second table only.