[英]unknown column in where clause in sql
SELECT *
FROM subjects
INNER JOIN entries ON entries.subject_id= subjects.subject_id
INNER JOIN students ON entries.student_id=students.student_id
WHERE subjects.exam_board LIKE ‘OCR’;
當我執行此操作時,where子句中的錯誤未知列“ OCR”
The following is my subject table
INSERT INTO subjects
(subject_id, subject_name, level_of_entry, exam_board)
VALUES
(1, 'chemistry', 'AS', 'OCR');
INSERT INTO subjects
(subject_id, subject_name, level_of_entry, exam_board)
VALUES
(2, 'biology', 'GCSE', 'AQA');
INSERT INTO subjects
(subject_id, subject_name, level_of_entry, exam_board)
VALUES
(3, 'music', 'GCSE', 'Edexcel');
下面是我的學生表
INSERT INTO students
(student_id,first_name,middle_name,last_name,email,password,reg_date)
VALUES
(NULL, 'Tom', 'Michael', 'ford', 'tom@yahoo.com','tom1234','2003/12/08');
INSERT INTO students
(student_id,first_name, middle_name, last_name, email, password, reg_date)
VALUES
(NULL, 'michael', 'scoffield', 'burrows', 'lincoln@yahoo.com', 'lincoln1234', '2001/12/16');
您必須在like子句中使用由`插入的'(單引號)符號,希望下面的代碼對您有所幫助
SELECT *
FROM subjects
INNER JOIN entries ON entries.subject_id= subjects.subject_id
INNER JOIN students ON entries.student_id=students.student_id
WHERE subjects.exam_board LIKE 'OCR';
SELECT *
FROM subjects
INNER JOIN entries ON entries.subject_id= subjects.subject_id
INNER JOIN students ON entries.student_id=students.student_id
WHERE subjects.exam_board LIKE 'OCR';
您使用了錯誤的報價類型。
您可能還想將自己的“喜歡”更新為
WHERE subjects.exam_board LIKE 'OCR%';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.