这个需求比较冷门,但对于在某些特定的情况下,还是会有这样的需要的.好在Oracle实现还比较方便,用存储过程则轻松实现. 查询字符串: create or replace procedure search_string(pString in varchar) as cursor all_tab_cursor is select a.owner, a.table_name, b.column_name from dba_tables a, dba_tab_columns b, dba_object
1.查询重复值: select code,count(*) as count from hospital group by code having count>1; 该语句查询code重复值大于1的记录 2.删除重复: DELETE FROM hospital WHERE id NOT IN (SELECT dt.minno FROM (SELECT MIN(id) AS minno FROM hospital GROUP BY code) dt); 该语句保留id最小的记录,其余code重复的
首先我们建立一张带有逗号分隔的字符串. CREATE TABLE test(id int(6) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id),pname VARCHAR(20) NOT NULL,pnum VARCHAR(50) NOT NULL); 然后插入带有逗号分隔的测试数据 INSERT INTO test(pname,pnum) VALUES('产品1','1,2,4'); INSERT INTO test(pname,pnum) VALUES('产
1.按 status 值 2 5 3 的顺序排序,值相同则按修改时间排序 order by FIELD(status,2,5,3),a.ModifyTime desc 2.将 status = 3 的记录排在最后,其余的记录按修改时间排序 order by FIELD(status,3),a.ModifyTime desc 原文地址:https://www.cnblogs.com/refuge/p/9636292.html