dongzheng7165 2014-07-15 11:25
浏览 8
已采纳

mysql选择查询显示在php中

I have a table named: '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

I have a php page where i have to add questions in exam_id '3' from table 'paper'. my query to insert question is as below:

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

I can also add a new question, so the query is:

INSERT INTO paper (question, exam_id) VALUES ('blah blah blah', '3')

It depends on question i select OR any new question i add.

Now, when i want to add more questions to exam_id '3' from table 'paper', it shows all the questions. My select query is as below:

SELECT * FROM paper WHERE exam_id != '3'

It shows all questions, but for instance i already added id = '23', so i dont want that question to display when i am adding more questions. Please help me with my select query. Let me know if i miss anything! Thanks in advance!

  • 写回答

2条回答 默认 最新

  • dosf40815 2014-07-15 11:50
    关注

    Okay I got it.....

    All I needed to do was, to fire the query again for not to repeat the questions that are selected previously....

    SELECT * FROM paper WHERE question = '$row['question']' AND exam_id = '3'
    if($select)
    {
        ************************* SHOW RESULT *********************
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度