【问题标题】:why the table is giving output like this?为什么表给出这样的输出?
【发布时间】:2019-09-22 08:33:55
【问题描述】:

我正在设置在线测试的 mcq 试卷。所以存储问题和选项的表格有这样的字段:

question_id -PRIMARY KEY ,question_description varchar(1000),option_a -varchar(100),option_b -varchar(100) ,option_c -varchar(100),option_d -varchar(100),answer -(int)

我要提出的问题是

Q) a and b volumes of solutions of concentration x% and y% respectively  by volume are mixed to form a new solution of resultant concentration z%. If it is known that z is less than the average of x and y, then:
1) a>b if x>y   2) a>b if x<y  3) a<b if x>=y  4) a<b if x<y 

所以当我将它插入表格时,选项没有以正确的方式出现。它是这样来的:

Q) a and b volumes of solutions of concentration x% and y% respectively by volume are mixed to form a new solution of resultant concentration z%. If it is known that z is less than the average of x and y, then:

1) a>b if x>y 2) a>b if x 3) a=y 4) a

为什么会出现这种输出?

1)a>b 如果 x>y

2)a>b 如果 x 3)a=y

4)a

插入语句是这样的:

INSERT INTO table_name(question_description,option_a,option_b,option_c,option_d,answer)
VALUES('Q) a and b volumes of solutions of concentration x% and y% respectively by volume are mixed to form a new solution of resultant concentration z%. If it is known that z is less than the average of x and y, then:','a>b if x>y   ','a>b if x<y  ','a<b if x>=y  ','a<b if x<y  ','1');

select 语句是这样的(这是第 5 个问题)

SELECT * from table_name WHERE  question_id = '5';

【问题讨论】:

  • 请添加您的插入语句。以及您的选择语句。
  • 如何插入数据?以及如何显示/查看它?
  • 鉴于缺少的部分都包含在 标签中,我建议这是关于您如何在前端和后端之间传递参数的问题。如果它们作为 xml 传递,则有一个嵌套标签 &lt;y 3) a&lt;b if x&gt;,然后是一个以 &lt;b if x&lt;y 开头的未终止标签
  • @P.Salmon 在这里我在问题中添加了我的插入语句和选择语句。请帮帮我
  • 你在mysql端的insert或者select都没有问题。你在哪里展示查询输出?

标签: mysql database sql-insert


【解决方案1】:

不知道,但是给定了

drop table if exists t;
create table t
(question_id int PRIMARY KEY ,
question_description varchar(1000),
option_a varchar(100),
option_b varchar(100) ,
option_c varchar(100),
option_d varchar(100),
answer int
);
insert into t values
(
1,
'a and b volumes of solutions of concentration x% and y% respectively  by volume are mixed to form a new solution of resultant concentration z%. If it is known that z is less than the average of x and y, then:',
'a>b if x>y',
'a>b if x<y',
'a<b if x>=y',
'a<b if x<y',
null
) 

select * from t;

+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+-------------+------------+--------+
| question_id | question_description                                                                                                                                                                                             | option_a   | option_b   | option_c    | option_d   | answer |
+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+-------------+------------+--------+
|           1 | a and b volumes of solutions of concentration x% and y% respectively  by volume are mixed to form a new solution of resultant concentration z%. If it is known that z is less than the average of x and y, then: | a>b if x>y | a>b if x<y | a<b if x>=y | a<b if x<y |   NULL |
+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+------------+-------------+------------+--------+
1 row in set (0.00 sec)

正如预期的那样。如果您正在做不同的事情,您需要告诉我们。

【讨论】:

    猜你喜欢
    • 2022-11-30
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    相关资源
    最近更新 更多