我正在尝试打印位于2个位置的帐户列表。这就是我所说的:
SELECT cust_id, account_id, product_cd
from account
SELECT name
from branch
where name = 'So. NH Branch' or name = 'Woburn Branch';
当我执行查询时,我收到以下消息:错误代码:1064 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'SELECT name附近使用正确的语法 来自分支
答案 0 :(得分:1)
我想你想加入表格
SELECT cust_id, account_id, product_cd
from account
INNER JOIN branch
ON account.colName = branch.colName -- the relationship between
-- the two tables
where name IN ('So. NH Branch', 'Woburn Branch');
但查询的另一种解释是您要执行多个查询。这样做时,每个语句应该用semi-colon
SELECT cust_id, account_id, product_cd
from account;
SELECT name
from branch
where name IN ('So. NH Branch', 'Woburn Branch');
答案 1 :(得分:0)
您想使用JOIN。你可以试试
SELECT cust_id, account_id, product_cd, name
FROM account, branch
WHERE name = 'So. NH Branch' or name = 'Woburn Branch';
但这取决于你的架构是否能正常工作
答案 2 :(得分:0)
这里有两个SQL语句,需要拆分或加入一个语句:
SELECT cust_id, account_id, product_cd
from account;
SELECT name
from branch
where name = 'So. NH Branch' or name = 'Woburn Branch';
SQL解释器在找到第二个;
之前正在寻找SELECT
。