Hey guys. I have a real simple Join here that I am having trouble with.
Here are the Fields of the two tables
tblCustomers
CustomerID(Primary/AutoIncriment), UserID, RO, FName, LName, Status, etc...
tblUsers
UserID(Primary/AutoIncriment), Username, Password, WriterName
Now, I am trying to get just CustomerID, UserID, RO, FName, LName from tblCustomers and WriterName from tblUsers based on the UserID, which is common to both tables.
So basically I have this code (Condensed version for easier understanding)
$UserID = 1;
$Show = "Active"
$Sql = "
SELECT tblCustomers.RO, tblCustomers.FName, tblCustomers.LName, tblCustomers.CustomerID, tblUsers.WriterName
FROM tblCustomers, tblUsers
WHERE Status = '$Show' AND UserID = '$UserID'";
I get errors with this version of the $Sql...but if I take out the UserID=UserID = '$UserID' part I dont get any errors, however it get way too many rows back..Its like it gives me 3 duplicates but with different WriterNames of each row in the Customers table.
Any Idea what I could be doing wrong here?
Thanks! 🙂