This question向我展示了如何创建一个函数,然后更新一个表,使第一个字母大写的列大写,这是非常复杂的?我只想输出FirstName和LastName大写第一个字母的结果。现在它们是全部大写,小写或格式正确的混合。
SELECT FirstName, LastName, r.Email, min(ListingID) as ListingID, ListingFirmID
FROM sancap_Residential_Property e
JOIN sancap_Agent r ON e.ListingAgentID = r.AgentID
JOIN sancap_Office d ON e.ListingFirmID = d.firmID
WHERE ListingFirmID != 'BrokerC'
GROUP BY FirstName, LastName, r.Email, ListingFirmID
答案 0 :(得分:0)
SELECT CONCAT(UPPER(LEFT(FirstName,1)), RIGHT(FirstName,LENGTH(FirstName) - 1)), CONCAT(UPPER(LEFT(LastName,1)), RIGHT(LastName,LENGTH(LastName) - 1)), r.Email, min(ListingID) as ListingID, ListingFirmID
FROM sancap_Residential_Property e
JOIN sancap_Agent r ON e.ListingAgentID = r.AgentID
JOIN sancap_Office d ON e.ListingFirmID = d.firmID
WHERE ListingFirmID != 'BrokerC'
GROUP BY FirstName, LastName, r.Email, ListingFirmID
答案 1 :(得分:0)
试试这个:
SELECT concat(UPPER(SUBSTRING(trim(FirstName),1,1)),lower(SUBSTRING(trim(FirstName),2))) as FirstName, concat(upper(substring(trim(LastName),1,1)),lower(substring(trim(LastName),2))) as LastName, r.Email, min(ListingID) as ListingID, ListingFirmID
FROM sancap_Residential_Property e
JOIN sancap_Agent r ON e.ListingAgentID = r.AgentID
JOIN sancap_Office d ON e.ListingFirmID = d.firmID
WHERE ListingFirmID != 'BrokerC'
GROUP BY FirstName, LastName, r.Email, ListingFirmID