Join many table with 1 query is the ideal. Because you must sure that
there are the valid data integrity. If there is only 1 broken join key
(any part of table1.key=table2.key), you'll got the null row. When you
need to display all of the first table value and retrieve another
information from other table, try to make more than 1 query like this
$qry1 = "select * from table1;";
$result = mysql_query($qry1, $mysql_link)
if ($result) {
while($row = mysql_fetch_array($mysql_result)) {
... display as you want before check value in another table
$qry2 = "select * from othertable where code='$row[cid]';";
$result2 = mysql_query($qry2, $mysql_link);
if ($result2) {
$row2 = mysql_fetch_array($result2);
if (trim($cname)=="") {
$cname = "N/A";
} else {$cname = trim($row2[name])."
".trim($row2[surname]);
}
} else {$cname = "N/A";}
print "$cname\n";
}
}
hope to help you,
Sommai,
At 23:34 31/3/2002 -0800, David McInnis wrote:
>Can anyone tell me a more efficient way to structure this query? It
>works fast enough now, but I don't have that much data yet. I am
>concerned with future performance.
>
>I need all of the rows from the project table that match the first where
>clause. The other information saves me from having to run a bunch of
>additional queries to get information that I need to display.
>
>select a.clientid, a.pid, a.writerid, a.dt_assigned,
> b.itemname,
> c.fname, c.lname, d.company
>fromprojects a,
> catalog b,
> clients c,
> partners d
>where a.writerid = 2 and
> a.sku = b.sku and
> a.clientid = c.id and
> c.partnerid = d.id;
>
>Thanks,
>
>David McInnis
>
>
>-
>Before posting, please check:
>http://www.mysql.com/manual.php (the manual)
>http://lists.mysql.com/ (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
--
Please be informed that all e-mail which are addressing to
thaithanakit.co.th will need to be changed to
BTsecurities.com by March 1, 2002 Thank you. :-)
--
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php