【发布时间】:2014-07-15 11:25:40
【问题描述】:
我有一个表名为:'paper' (question_bank)
id | exam_id | question
1 | 1 | What will be 35*9?
2 | 1 | What will be 5-9?
3 | 1 | A + B
4 | 1 | What is a circle?
5 | 1 | If we have four corners with equal height and width, then which shape is that?
6 | 1 | What is Maths?
7 | 1 | What is a triangle?
21 | 1 | what is Nikhil surname?
22 | 2 | Last name of Bhavesh is
23 | 2 | Last name of Harsh is
27 | 3 | What is Maths?
28 | 3 | What is a triangle?
30 | 3 | Last name of Harsh is
我有一个 php 页面,我必须在“paper”表中的“exam_id”“3”中添加问题。我插入问题的查询如下:
INSERT INTO paper (question exam_id) SELECT question, '3' FROM paper WHERE id = '2'
OR
INSERT INTO paper (question exam_id) SELECT question, '3' FROM paper WHERE id = '1'
OR
我还可以添加一个新问题,所以查询是:
INSERT INTO paper (question, exam_id) VALUES ('blah blah blah', '3')
这取决于我选择的问题或我添加的任何新问题。
现在,当我想从表'paper' 中向exam_id '3' 添加更多问题时,它会显示所有问题。我的选择查询如下:
SELECT * FROM paper WHERE exam_id != '3'
它显示所有问题,但例如我已经添加了 id = '23',所以我不希望在添加更多问题时显示该问题。请帮助我进行选择查询。如果我想念什么,请告诉我!提前致谢!
【问题讨论】:
-
我不明白。您正在使用
exam_id != 3查询所有问题,但您不希望使用id=23的问题?没有意义,因为后者满足您在 where 子句中给出的条件 -
因为我已经在exam_id = 3 中添加了id = 23,所以我不想在向exam_id = 3 添加更多问题时显示该问题
标签: php database select mysqli