Forum Moderators: open

Message Too Old, No Replies

unknown column '#*$!' in 'where clause' error

I need help re-writing this sql statement

         

dainstructor

7:17 pm on Mar 30, 2007 (gmt 0)

10+ Year Member



For some reason I am recieving this error while trying to pull data from a customer database. The crazy thing is it only happens while trying to pull employees with both letters and numbers in their employee id. I wasn't sure what was causing it so I searched this site and found a similar thread:
[webmasterworld.com...]

This thread recommends not combining comma joins and left joins as I am with my search. The statement I have is below:

mysql_select_db($database_master_user, $master_user);
$query_getAssignment = "SELECT *, projects.projectName FROM assignments LEFT JOIN projects USING (projectID) WHERE assignments.empNo =".$employeeNo . " ORDER BY assignments.projectID";

Can someone help me phrase this so that I do not need to mix comma and inner joins? Or does anyone know of another way around this problem?

Thanks in advance,

Clark

9:18 pm on Mar 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I find your question a bit confusing. First of all, I prefer to format SQL statements on separate lines so it's easier to read and therefore debug:

SELECT *, projects.projectName
FROM assignments
LEFT JOIN projects
USING (projectID)
WHERE assignments.empNo =".$employeeNo . "
ORDER BY assignments.projectID

Ah...well I'm wondering if your quotes are messing this up.

Can you paste the full error, where it repeats the SQL statement. I want to see how MySQL is translating the $employeeNo variable.