1

我有这个查询来从 Full_Name 字段中检索名字。

SELECT Employee_Table.Full_Name, Left([Full_Name],InStr([Full_Name]," ")-1) AS First_Name
FROM Employee_Table;

它工作正常,

但是,我尝试通过将查询更改为此查询来更改查询以将姓氏放入 Last_Name 字段,但它不起作用。请帮忙

SELECT Employee_Table.Full_Name, Right([Full_Name],InStr([Full_Name]," ")+1) AS Last_Name
FROM Employee_Table;

我希望只有一个查询可以提取信息,而不是两个单独的查询。

谢谢

问候

4

1 回答 1

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;
于 2013-08-09T03:37:46.293 回答