我有一個名爲表:「紙」(question_bank)MySQL的選擇查詢顯示在PHP
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頁面,我從表「紙」在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')
這取決於問題我選擇或任何新的問題,我補充。
現在,當我想從table'paper'向exam_id'3'添加更多問題時,它會顯示所有問題。我的選擇查詢如下:
SELECT * FROM paper WHERE exam_id != '3'
它顯示了所有的問題,但比如我已經添加ID =「23」,所以我不想這個問題,當我加入了更多的問題來顯示。請幫我選擇查詢。讓我知道如果我錯過任何東西!提前致謝!
我不明白。你正在用'exam_id!= 3'查詢所有的問題,但是你不想用'id = 23'這個問題?沒有任何意義,因爲後者符合條款 – paubo147
中的條件,因爲我已經在exam_id = 3中添加了id = 23,我不想在向exam_id = 3 –