Luignata
03-03-2009, 02:17 AM
I'm trying to use join two queries into a single query using JOIN. However... doesn't seem to be working.
$getData = @mysql_query("SELECT `a`.`user`,`a`.`data`,`a`.`cost`,`b`.`name` FROM `table_a` `a` JOIN `table_b` `b` ON `a`.`user`=`b`.`user`");
I'm unsure how to display my tables, so I resorted to just creating two simple tables on my own website. If you do not feel it's safe to start randomly clicking links, below is a copy of the HTML code that you can post somewhere so you don't have to click the link if you feel unsafe about it.
http://www.intotheunknownls.com/tables.html
<TABLE BORDER=1><TR><TD COLSPAN=3>Table A</TD></TR>
<TR><TD>User</TD><TD>Data</TD><TD>Cost</TD></TR>
<TR><TD>1</TD><TD>Data1</TD><TD>Cost1</TD></TR>
<TR><TD>2</TD><TD>Data2</TD><TD>Cost2</TD></TR></TABLE>
<TABLE BORDER=1><TR><TD COLSPAN=2>Table B</TD></TR>
<TR><TD>User</TD><TD>Name</TD></TR>
<TR><TD>1</TD><TD>Name1</TD></TR>
<TR><TD>2</TD><TD>Name2</TD></TR></TABLE>
I think I'm going about joining in all the wrong ways but.. bah. I just need to be able to use the "User" column from Table A to determine which rows to get in Table B. "User" will always be the same in both tables.
$getData = @mysql_query("SELECT `a`.`user`,`a`.`data`,`a`.`cost`,`b`.`name` FROM `table_a` `a` JOIN `table_b` `b` ON `a`.`user`=`b`.`user`");
I'm unsure how to display my tables, so I resorted to just creating two simple tables on my own website. If you do not feel it's safe to start randomly clicking links, below is a copy of the HTML code that you can post somewhere so you don't have to click the link if you feel unsafe about it.
http://www.intotheunknownls.com/tables.html
<TABLE BORDER=1><TR><TD COLSPAN=3>Table A</TD></TR>
<TR><TD>User</TD><TD>Data</TD><TD>Cost</TD></TR>
<TR><TD>1</TD><TD>Data1</TD><TD>Cost1</TD></TR>
<TR><TD>2</TD><TD>Data2</TD><TD>Cost2</TD></TR></TABLE>
<TABLE BORDER=1><TR><TD COLSPAN=2>Table B</TD></TR>
<TR><TD>User</TD><TD>Name</TD></TR>
<TR><TD>1</TD><TD>Name1</TD></TR>
<TR><TD>2</TD><TD>Name2</TD></TR></TABLE>
I think I'm going about joining in all the wrong ways but.. bah. I just need to be able to use the "User" column from Table A to determine which rows to get in Table B. "User" will always be the same in both tables.