一次数据库的整理的sql语句
//查询以井结束的记录
SELECT f_wellnumber, SUBSTRING(f_wellnumber, 1, LEN(f_wellnumber) - 1)
AS Expr1
FROM CY_wellrecord
WHERE (f_wellnumber LIKE '%井')
//替换井字
UPDATE CY_wellrecord
SET f_wellnumber = SUBSTRING(f_wellnumber, 1, LEN(f_wellnumber) - 1)
WHERE (f_wellnumber LIKE '%井')
//查询中间带空格的记录
SELECT f_wellnumber, REPLACE(f_wellnumber, ' ', '') AS Expr1
FROM CY_wellrecord
WHERE (f_wellnumber LIKE '% %')
//替换中间的空格
UPDATE cy_wellrecord
SET f_wellnumber = REPLACE(f_wellnumber, ' ', '')
FROM CY_wellrecord
WHERE (f_wellnumber LIKE '% %')
//更新id
UPDATE a
SET a.f_wellid = b.f_id
FROM cy_wellrecord a, cy_well b
WHERE a.f_wellnumber = b.f_name