Mysql inner join problem | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Mysql inner join problem

Hi, I am trying to use Inner Join to join two tables.<br />My first table name <b>Ni</b><br />CustomerID<br />OrderID<br /><br />My second table name <b>Be</b><br />OrderID<br />BusinessID<br />BusinessName<br />BusinessAddress<br /><br />I tried this SQL but it didn’t work…..Anyone have any comment !!<br /><br />"Select Ni.CustomerID,Ni.OrderID from Ni Inner Join Be on Ni.OrderID=Be.OrderID where Ni.CustomerID =$CustomerID ";v[<img src=’/community/emoticons/emotion-6.gif’ alt=’:(‘ />]
Did you get error?
Did it show wrong result?
Post tables structures, sample data and the result you want Madhivanan Failing to plan is Planning to fail
You may also get better answers on sites dedicated to MySQL – though there are some members here with knowledge beyond Microsoft SQL Server.
The SQL youve pasted is fine, except youve pasted what appears to be PHP not pure SQL.
My guess is that the variable $CustomerID is not what you expect it to be, perhaps its unset, or ” ? $query = "Select Ni.CustomerID,Ni.OrderID from Ni Inner Join Be on Ni.OrderID=Be.OrderID where Ni.CustomerID =$CustomerID";
echo $query; // make sure you look at the sql being generated, instead of assuming its right if ($rs == mysql_query($query))
{
// do your magic
}
else
echo mysql_error(); // mysql_error is your friend!
]]>