Unknown Column

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Unknown Column

Post by kendall »

Code: Select all

SELECT
  Website, 
  Requirement, 
  State, 
  Date, 
  Month, 
  Year, 
  CollegeName AS College, 
  AdID, 
  Association, 
  college_vacancies.Position, 
  college_vacancies.Sport, 
  DATE_FORMAT(Date,'%%a %%D %%b %%y') AS TheDate, 
  Sex, State 
FROM 
  college_vacancies, 
  colleges_list 
RIGHT JOIN 
  students_information AS student 
ON 
  student.Position = college_vacancies.Position 
WHERE 
  college_vacancies.CollegeID = colleges_list.CollegeID 
  AND college_vacancies.Sport = student.Sport 
  AND college_vacancies.Position = student.Position 
  AND Gender = Sex AND student.STUDENTID = %s 
  AND college_vacancies.`Status` = 1 
ORDER BY 
  Date DESC, 
  Association
The above statement should bring up the vacancies whose Sport and Position match those in the students. However in trying to execute the statement i get a
Unknown column 'college_vacancies.Position' in 'on clause'
I'm not sure whats wrong as the column exists :?: :?:

Jcart | Much easier to read the query now isn't it? Please post long queries in a formatted fashion in the future please.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

Try removing the parentheses in the "on" clause. They're not required, and possibly they are not being parsed correctly.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If ~califdon's suggestion doesn't help much, can you post "SHOW CREATE TABLE foo" outputs for the tables?

Also, it would help to see your SELECT query formatted for reading.
Post Reply