Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MySQL中,租赁列表不再附加到用户ID_Mysql_Relational Database - Fatal编程技术网

在MySQL中,租赁列表不再附加到用户ID

在MySQL中,租赁列表不再附加到用户ID,mysql,relational-database,Mysql,Relational Database,我有一个数据库,每个租赁都有一个唯一的ID,每个租赁都通过一个用户ID链接到一个用户。实际上,在我之前的人在删除记录(包括租赁)之前删除了该用户 我尝试将user.id与其关联的rental.id连接起来,其中user.id为NULL,但无法在NULL用户id上连接。下面是我运行的一个MySQL查询示例,我更改了命名约定,使其与数据库不匹配 SELECT user.email, user.id, user.name, rent.lastChanged, rent.id, rent

我有一个数据库,每个租赁都有一个唯一的ID,每个租赁都通过一个用户ID链接到一个用户。实际上,在我之前的人在删除记录(包括租赁)之前删除了该用户

我尝试将user.id与其关联的rental.id连接起来,其中user.id为NULL,但无法在NULL用户id上连接。下面是我运行的一个MySQL查询示例,我更改了命名约定,使其与数据库不匹配

        SELECT user.email, user.id, user.name, rent.lastChanged, rent.id, rent.address
        FROM rental rent LEFT JOIN rentList ON rental.id = rentList.id
        RIGHT JOIN user ON user.id = rentList.id
        WHERE user.id NOT REGEXP '^-?[0-9]+$'
我试着加入一个用户不是数字的地方,即空,但没有运气。希望通过在租金上设置参数来防止这种情况。对此有任何见解都将不胜感激

null不是字符串。所以您必须使用is null

SELECT user.email, user.id, user.name, rent.lastChanged, rent.id, rent.address
        FROM rental rent LEFT JOIN rentList ON rental.id = rentList.id
        RIGHT JOIN user ON user.id = rentList.id
        WHERE user.id i null