I want to do the simpliest thing and its not working.
I have one table called serials
It contains all serial numbers of many products
Fields:
serialID (primary key)
ownerID (interger)
serialNum (varChar)
Other table is called serialowners – and contains owners of serial numbers
Fields:
ownerID (primary key – interger)
serialNum (varChar -I want to remove this field in this table because it is duplicate data)
fName
lName
etc.
One owner may have multiple serialNum but there may be serial numbers entered where an owner has not registered so there may or may not be a matching row in the serialowners table.
I want to display ALL serial numbers and if they have an owner, that info will display and if not, the serial number will still display. Should be such a simple thing with a LEFT JOIN
Here is my query:
[CODE]
$query = mysql_query(“SELECT * FROM serials
LEFT JOIN serialowners
USING (ownerID)
ORDER BY serialNum
“);
When using this query, I get an error and nothing is returned
However, if I change the query to the following (the USING line), it displays the data correctly and pulls all serialNum from the serials table
[CODE]
$query = mysql_query(“SELECT * FROM serials
LEFT JOIN serialowners
USING (serialNum)
ORDER BY serialNum
“);
I want to remove the serialNum from the serialowners table because I want to tie the 2 tables together with ownerID which are integer values.
So why can’t I run the first query using the ownerID ? There is something going on with it being an integer because the varChar of serialNum works correctly.
I hope this makes sense.
Can someone help me please?