这将适用于SQL Server。如果使用其他方法,则需要找出left和charindex的相应功能。当然,可以用子字符串替换Left。
select distinct left(T.Animal, charindex(' ', T.Animal, 1)-1)from YourTable as T结果:
-------------------------BIRDCATDOGFISH
在MySQL中,您将使用left和locate。(代码未经测试)
select distinct left(T.Animal, locate(' ', T.Animal, 1)-1)from YourTable as T


