我想从表中选择除一行之外的所有值数据。我该怎么做?
table = teachers
headers = TeacherID, Password, FirstName, Surname
TeacherID = teacher
当我尝试
时SELECT *
FROM teachers
EXCEPT
SELECT *
FROM teachers
WHERE TeacherID = 'teacher'
我收到错误
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM teachers WHERE TeacherID = teacher LIMIT 0, 30' at line 1
答案 0 :(得分:0)
这将选择列TeacherID
不包含值teacher
Select * from teachers where TeacherID != 'teacher'
我不确定您的列TeacherID是否为字符串,如果是,请不要将其命名为ID。 ID通常是int数据类型。
如果要选择列TeacherID
包含值teacher
的所有记录,请执行此操作
SELECT *
FROM teachers
WHERE TeacherID = 'teacher'
答案 1 :(得分:0)
你应该
select * from teachers where TeacherID != 'teacher'
OR
select * from teachers where TeacherID not in ('teacher','teacher1','teacher2')