Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Question - Need Help

Status
Not open for further replies.

TheDeaner

Technical User
Oct 13, 2004
11
US
I have a basic question that I hope someone can help me with. I need to grab info from two different tables but don't know how.

$sql_statement = "SELECT * FROM table1, table2 where table1.item_id = \"$ARG\" && table2.item_id = \"$ARG\"";
$result = mysql_query($sql_statement) or die(mysql_error());

while($misc = mysql_fetch_array( $result ))



When I put the $item = $misc[0]; statement in I can only get the items from the first table only. I think I need to link them or something. Any help would be appreciated.

Thanks
Dean
 

Something like:

Code:
$sql_statement = "
   SELECT * 
     FROM table1, table2
    WHERE table1.item_id = table2.item_id AND
          table1.item_id = '$ARG'";

$result = mysql_query($sql_statement) or die(mysql_error());

while($misc = mysql_fetch_array( $result ))



*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top