http://www.tablesgenerator.com/
'Programming' + 5
-
[ CSS ] table 자동으로 생성
2017.09.06 -
[ CSS ] 네비게이션바 링크
2017.08.08 -
[MSSQL] 검색 : 특정 테이블에서 모든 컬럼의 특정 문자열 데이터 찾기
2017.03.07 -
[jQuery] 테이블 정렬 플러그인 : tablesorter 사용하기
2017.02.24 -
[MYSQL] SubQuery 사용법
2016.06.16
'Programming > Script' 카테고리의 다른 글
[jQuery] 테이블 정렬 플러그인 : tablesorter 사용하기 (0) | 2017.02.24 |
---|
게시판의 검색기능을 구현하는데 컬럼명을 선택하는 것이 아닌
모든 컬럼에서 알아서 검색하길 원했다.
구현하기 위해서는 프로시저의 생성이 먼저 필요했다.
[ MSSQL SP 생성 ]
CREATE PROCEDURE sp_FindStringInTable @stringToFind VARCHAR(100), @schema sysname, @table sysname AS DECLARE @sqlCommand VARCHAR(8000) DECLARE @where VARCHAR(8000) DECLARE @columnName sysname DECLARE @cursor VARCHAR(8000) BEGIN TRY SET @sqlCommand = 'SELECT * FROM [' + @schema + '].[' + @table + '] WHERE' SET @where = '' SET @cursor = 'DECLARE col_cursor CURSOR FOR SELECT COLUMN_NAME FROM ' + DB_NAME() + '.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ''' + @schema + ''' AND TABLE_NAME = ''' + @table + ''' AND DATA_TYPE IN (''char'',''nchar'',''ntext'',''nvarchar'',''text'',''varchar'')' EXEC (@cursor) OPEN col_cursor FETCH NEXT FROM col_cursor INTO @columnName WHILE @@FETCH_STATUS = 0 BEGIN IF @where <> '' SET @where = @where + ' OR' SET @where = @where + ' [' + @columnName + '] LIKE ''' + @stringToFind + '''' FETCH NEXT FROM col_cursor INTO @columnName END CLOSE col_cursor DEALLOCATE col_cursor SET @sqlCommand = @sqlCommand + @where --PRINT @sqlCommand EXEC (@sqlCommand) END TRY BEGIN CATCH PRINT 'There was an error. Check to make sure object exists.' IF CURSOR_STATUS('variable', 'col_cursor') <> -3 BEGIN CLOSE col_cursor DEALLOCATE col_cursor END END CATCH
[ 사용 방법 ]
-- " 를 값으로 가지고 있는 A_Table의 모든 row 찾기. EXEC sp_FindStringInTable '%"%', 'dbo', 'A_Table' -- 2015로 시작하는 값을 가지고 있는 A_Table의 모든 row 찾기. EXEC sp_FindStringInTable '2015%', 'dbo', 'A_Table'
'Programming > DB' 카테고리의 다른 글
[MYSQL] SubQuery 사용법 (0) | 2016.06.16 |
---|
1. 원본 내용
tablesorter 소개에 대해선 http://tablesorter.com/docs/에서 확인 가능.
2. 다운로드
http://tablesorter.com/docs/#Download에서 다운로드
3. 사용하기
1) 헤더에 플러그인 포함하기
header.php
Security <-- option --> });
2) 테이블에 class 값 입력하기
class="tablesorter" 이 클래스명은 변경하면 안된다. ( 적용 안됨 )
index.php
ID | Auth | Date | User | Source IP | Remote IP | Level |
---|---|---|---|---|---|---|
ID | Auth | Date | User | Source | Remote | Level |
3) 스크립트 실행하기
- 기본 실행 방법
main.js
$(function(){ $("#logtable").tablesorter(); });
- 컬럼별 오름차순 내림차순 적용하기
sortList: [[0,1]] 의 경우 1번째 컬럼의 1: desc 내림차순 (5,4,3,2,1) 정렬한다는 의미
sortList: [[3,1],[5,0]] 의 경우 4번째 컬럼의 desc 내림차순 정렬 , 6번째 컬럼의 asc 오름차순 정렬한다는 의미
$(document).ready(function() { // call the tablesorter plugin $("#logtable").tablesorter({ // sort on the first column, order asc [coulum num,asc=0 or desc=1] sortList: [[0,1]] }); }); });
4) 여러가지 데모 및 예제
데모 확인 하기 http://tablesorter.com/docs/#Demo
예제 확인 하기 http://tablesorter.com/docs/#Examples
'Programming > Script' 카테고리의 다른 글
[ CSS ] 네비게이션바 링크 (0) | 2017.08.08 |
---|
실행하고 싶은 쿼리다.
Sub쿼리를 따로 실행하면 결과도 잘나오고, 전체 실행을 하니 아래와 같은 결과가나왔다.
[ 실패한 쿼리 ]
UPDATE [TABLE] SET [Coloum] = '[값]'
WHERE [Coloum] IN
( SELECT MAX( [Coloum] ) FROM serverinfo WHERE [Coloum2] = '[값2]' )
AND [Coloum2] = '[값2]'
[MYSQL ERROR]
You can't specify target table 'serverinfo' for update in FROM clause
원인 :
서브쿼리 수행할 시에 서브쿼리의 From절안에 기본쿼리의 테이블과 서브쿼리의 테이블을 같은테이블을 사용 할수 없다는 내용. 업데이트 및 타겟 모두를 위해,
같은테이블 안에서 UPDATE와 DELETE는 사용할 수 없다.
해결 : 서브쿼리로 한번 더 감싸 주었더니 정상실행 되었다.
[ 성공한 쿼리 ]
UPDATE [TABLE] SET [Coloum] = '[값]'
WHERE [Coloum] IN
( SELECT * FROM
( SELECT MAX( [Coloum] ) FROM serverinfo WHERE [Coloum2] = '[값2]' )
as temp )
AND [Coloum2] = '[값2]'
'Programming > DB' 카테고리의 다른 글
[MSSQL] 검색 : 특정 테이블에서 모든 컬럼의 특정 문자열 데이터 찾기 (0) | 2017.03.07 |
---|