update 表名 set 列1='yr' where 列1='hr'
如果換成REPLACE函數的話,具體語句如下:
update 表名 set 列1=replace(列1,'hr','yr') where 列1='hr'
以上語句的測試過了。
2. SQL條件查詢替換
update news set CONTEMT= REPLACE ( CONTEMT,'HTM', 'HTM1') where type=40
解釋:
update 表名 set 欄位名= REPLACE ( 欄位名,'被替換的值', '替換成') where 條件
3. 根據條件批量替換的SQL語句怎麼寫
用sql的批量更新功能,把要替換字元替換成想要替換成的字元。 sql替換語句,用該命令可以整批替換某欄位的內容,也可以批量在原欄位內容上加上或去掉字元。
4. sql語句條件中值替換!
update name set name="SASD.A" where name='SASD''A'
select * from name where name="SASD.A"
5. SQL 查詢兩個表,符合條件替換,不符合直接顯示
以下是 SQLServer 的寫法
Select 序號,組件,料號,
IsNull(MARK,'') as MARK,描述,點位
From 表A
full join 表B
On 表A.組件 =表B.料號
6. 動態實現sql查詢條件替換
<select id="queryEmp" resultType="cn.test.entity.Emp">
select * from emp where 1=1
<if test="deptNo!=null">
and deptno=#{deptNO}
</if>
<if test="deptName!=null">
and deptno=#{deptName}
</if>
</select>
註:<if test="deptNo!=null">中 的deptNo是指實體類中的屬性或欄位;
choose:
<select id="queryEmp" resultType="cn.test.entity.Emp">
select * from emp where 1=1
<choose>
<when test="deptNo!=null">
and deptno=#{deptNo}
</when>
<when test="deptName!=null">
and deptname=#{deptName}
</when>
<otherwise>
and personnum>#{personNum}
</otherwise>
</choose>
</select>
7. sql語句條件中值替換!
引文英文半形的單引號 「'」 是select語句的保留字,所以直接在條件中使用時是被認為限定字元串了,解決的辦法是利用ascii碼來轉,使用chr(39)來代替單引號即可。
例如:查詢name欄位中含有「'」的姓名,使用如下sql語句。
select * from name where name like '%' & chr(39) & '%'
這樣就能查詢到姓名中包含英文半形單引號的記錄了。
8. 如何對sql資料庫中的某一欄位進行替換
1.SQL欄位名稱替換,可以用AS。x0dx0a如:select ID,NAME as 姓名 from tablex0dx0a2.替換某欄位某些行的值可以用update。x0dx0a如:update table set Name='zhang san' where name='條件表達式'x0dx0a3.列值替換還有replace函數。x0dx0a x0dx0a答案:update 表名 set 列1='yr' where 列1='hr' x0dx0arepalce(要置換的欄位,需要替代的字元,替換後的字元)x0dx0aupdate 表名 set 列1=replace(列1,'hr','yr');
9. sql如何根據條件替換得到需要的值
update 表名 set 名稱2=A.名稱1 from(select ID1,名稱1 from 表名)A where 表名.ID2=A.ID1