小编mik*_*ike的帖子

'having子句'中的未知列

我需要在sakila数据库中找到电影的最长租期.我试过这个:

  SELECT DISTINCT
      customer.first_name
    FROM
      rental,
      customer
    WHERE
      rental.customer_id = customer.customer_id
    GROUP BY
      rental.rental_id
    HAVING
      (
        rental.return_date - rental.rental_date
      ) =(
      SELECT
        MAX(countRental)
      FROM
        (
        SELECT
          (
            rental.return_date - rental.rental_date
          ) AS countRental
        FROM
          rental,
          customer
        GROUP BY
          rental.rental_id
      ) AS t1
    )
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

1054 - 'having子句'中的未知列'rental.return_date'

有谁知道为什么?我使用了一个应该是聚合数据的列..我缺少什么

mysql sql database having-clause

17
推荐指数
1
解决办法
2万
查看次数

通过父级执行命令时使用管道

我要实现一个无名管道,我必须在父进程中执行该命令,而不是在他的任何一个孩子中执行.每个" - "等于一个管道("|")的调用,也是我有这个代码的赋值的一部分.谁能向我解释为什么它不起作用?

#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h> // for open flags
#include <time.h> // for time measurement
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

void my_exec(char* cmd, char** argv)
{
    int pipefd[2], f;

    if (pipe(pipefd) < 0)
        perror("pipe creation failed");

    f = fork();
    assert(f >= 0);

    if (f == 0) {
        // inside son process - connecting STDOUT to pipe write
      if (dup2(pipefd[1], STDOUT_FILENO) < 0)
            perror("dup2 failed");

        close(pipefd[0]);
        close((int)stdout);


    } …
Run Code Online (Sandbox Code Playgroud)

c linux pipe

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

sftp避免在找不到文件时退出

我有这个脚本:

filePattern='sor.log*'
filePattern2='sor.SOR.log*'
myLocation=/opt/tradertools/omer
clientLocation=/opt/tradertools/omer/sor/from
clientName=vmonitorlmpa
clientUser=root
clientPass=triltest

export SSHPASS=$clientPass

sshpass -e sftp -oStrictHostKeyChecking=no -oBatchMode=no -b - $clientUser@$clientName << !

    get $clientLocation/$filePattern2 $myLocation
    get $clientLocation/$filePattern $myLocation

   bye
!
Run Code Online (Sandbox Code Playgroud)

但如果filepattern2没有找到,它将退出.如何避免使用两个SFTP连接?

bash sftp

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

C二进制文件与文本文件效率

我是C的新人,我想要一些帮助.假设我需要在文件中存储仅6位数字.(假设int的大小等于4)使用文本文件或二进制文件会更有效(就内存而言)?我不确定如何面对这个问题,欢迎任何帮助

c binary text file

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

标签 统计

c ×2

bash ×1

binary ×1

database ×1

file ×1

having-clause ×1

linux ×1

mysql ×1

pipe ×1

sftp ×1

sql ×1

text ×1