我有这个查询从Full_Name字段中检索名字。
SELECT Employee_Table.Full_Name, Left([Full_Name],InStr([Full_Name]," ")-1) AS First_Name
FROM Employee_Table;
一切正常,
但是,我尝试通过将查询更改为此查询来更改查询以将Last Name设置为Last_Name字段,但它不起作用。请帮忙
SELECT Employee_Table.Full_Name, Right([Full_Name],InStr([Full_Name]," ")+1) AS Last_Name
FROM Employee_Table;
我希望只有一个查询来提取信息,而不是两个单独的信息。
谢谢
此致
答案 0 :(得分:2)
在第二个查询中,您将从字符串的末尾拉出,但长度是从头开始。哎呀。您想要的功能是MID()
而不是RIGHT()
:
SELECT Employee_Table.Full_Name, Left([Full_Name],InStr([Full_Name]," ")-1) AS First_Name,
mid([Full_Name],InStr([Full_Name]," ")+1) as Last_Name
FROM Employee_Table;