如何正确地将具有 3 个特定单元格的 3 列添加到 MySQL 上的 table?

How to correctly add 3 columns with 3 particular cells to a table on MySQL?

注意:以下信息仅出于教育目的人工创建。

以下查询:

SELECT * FROM dapp.credentials WHERE id = ( SELECT MAX(id) FROM dapp.credentials )

获取以下行:

|  id  | email          | password       | first_name | member_type | validated |
---------------------------------------------------------------------------------
|  5000|perkins@drit.com|1234perkins     |Mickey      | regular     |1          |

现在另一个查询:

SELECT cellphone, address, zipcode FROM dapp.members
WHERE user_id = ( SELECT MAX(user_id) FROM dapp.members )

获取另一行:

| cellphone     | address             | zipcode | 
-------------------------------------------------
| (787)-142-6952|4108 Wheeler Ridge Dr|99563    |

那么,如何创建一个查询来获取这样的行?

|  id  | email          | password       | first_name | member_type | validated || cellphone     | address             | zipcode | 
----------------------------------------------------------------------------------------------------------------------------------
|  5000|perkins@drit.com|1234perkins     |Mickey      | regular     |1          || (787)-142-6952|4108 Wheeler Ridge Dr|99563    |

我试过这个查询:

SELECT * FROM dapp.credentials WHERE id = ( SELECT MAX(id) FROM dapp.credentials )
JOIN
(SELECT cellphone, address, zipcode FROM dapp.members
WHERE user_id = ( SELECT MAX(user_id) FROM dapp.members ))

但是我得到了这个错误:

SQL Error [1064] [42000]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN (SELECT cellphone, address, zipcode FROM dapp.members WHERE user_id = ( S' at line 2

请问我上次查询有什么问题吗?

您可以 CROSS 连接 2 个查询:

SELECT t1.*, t2.*
FROM (
  SELECT * 
  FROM dapp.credentials 
  WHERE id = (SELECT MAX(id) FROM dapp.credentials)
) t1 CROSS JOIN (
  SELECT cellphone, address, zipcode 
  FROM dapp.members 
  WHERE user_id = (SELECT MAX(user_id) FROM dapp.members)
) t2;