我一直在尝试使用别名来更改列名
我有三个表:姓名,成员和付款
我从互联网上采用了两种不同的语法,我尝试了两种语法
第一个:
SELECT n.firstname AS [First Name], n.lastname AS [Last Name], m.username AS UserName,
m.birthday AS Birthday, m.email AS Email, m.phone_no AS Phone,
p.MembershipType AS [Membership Type]
FROM member AS m, name AS n, payment AS p
WHERE (m.username = n.username) and (m.username = p.username)
ORDER by n.firstname;
第二个:
SELECT n.firstname 'First Name', n.lastname 'Last Name', m.username
'UserName', m.birthday 'Birthday',
m.email 'Email', m.phone_no 'Phone', p.MembershipType 'Membership Type'
FROM member m, name n, payment p
WHERE (m.username = n.username) and (m.username = p.username)
ORDER by n.firstname;
但它显示" FROM关键字未找到预期的位置" 我做错了什么?
答案 0 :(得分:0)
我假设您使用的是 Oracle 数据库。
如果alias_name包含空格,则必须将alias_name括在引号
中因此您的查询可能如下所示:
SELECT n.firstname "First Name", n.lastname "Last Name", m.username
"UserName", m.birthday "Birthday",
m.email "Email", m.phone_no "Phone", p.MembershipType "Membership Type"
FROM member m, name n, payment p
WHERE (m.username = n.username) and (m.username = p.username)
ORDER by n.firstname;