小编Kum*_*thy的帖子

MySQL错误1241:操作数应包含1列

我试图将table1中的数据插入table2

insert into table2(Name,Subject,student_id,result)
select (Name,Subject,student_id,result)
from table1;
Run Code Online (Sandbox Code Playgroud)

table2的关键是student_id.

假设没有任何重复.

我收到错误: MySQL error 1241: Operand should contain 1 column(s)

table2中只有四列.

mysql sql select insert mysql-error-1241

51
推荐指数
3
解决办法
13万
查看次数

MySQL中的百分比 - 在同一个表中的两列之间

我有一个MySQL表,看起来像这样:

Name    | Pass |  Fail | Pass Percent | Fail Percent

Abdy    | 20   |  5    |              |
Bob     | 10   |  5    |              |
Cantona | 40   |  10   |              |
Dave    | 30   |  20   |              |
Run Code Online (Sandbox Code Playgroud)

我想要获得百分比:

喜欢:passpercent =(传递/传递+失败)*100

我可以用两个列的单个MySQL代码填充表吗?

表有希望看起来像这样:

Name    | Pass |  Fail | Pass Percent | Fail Percent

Abdy    | 20   |  5    |   80         |  20
Bob     | 10   |  5    |   66         |  33
Cantona | 40   |  10   | …
Run Code Online (Sandbox Code Playgroud)

mysql select insert percentage

5
推荐指数
1
解决办法
5479
查看次数

在Go中为httptest.NewServer使用自定义URL

我通过使用Go语言创建http测试服务器在一些其他电话上运行UT。我的代码如下。

type student struct{
FirstName string
LastName string
}

func testGetStudentName() {
    testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    response = new(student)
    response.FirstName = "Some"
    response.LastName = "Name"
    b, err := json.Marshal(response)
    if err == nil {
            fmt.Fprintln(w, string(b[:]))
        }
    }))
    defer ts.Close()
    student1 := base.getStudent("123")
    log.Print("testServerUrl",testServer.URL) //prints out http://127.0.0.1:49931 ( port changes every time this is run)

   ts.URL = "http://127.0.0.1:8099" //this assignment does not quite change the URL of the created test server.
}
Run Code Online (Sandbox Code Playgroud)

在要测试的文件中,

var baseURL = "http://originalUrl.com" …
Run Code Online (Sandbox Code Playgroud)

unit-testing http go

1
推荐指数
1
解决办法
2564
查看次数

标签 统计

insert ×2

mysql ×2

select ×2

go ×1

http ×1

mysql-error-1241 ×1

percentage ×1

sql ×1

unit-testing ×1