MySQL (2) 썸네일형 리스트형 [python] mysql 백업파일에서 특정 테이블 부분만 별도로 저장하기 import reimport argparsedef extract_table_data(input_file, output_file, table_name): with open(input_file, 'r', encoding='utf-8') as infile, open(output_file, 'w', encoding='utf-8') as outfile: in_table = False table_content = [] for line in infile: if line.strip().startswith(f"DROP TABLE IF EXISTS `{table_name}`"): in_table = True .. [mysql] 특정필드에 빈자료를 먼저 출력하고, 높은값순으로 뒤에 출력하기 select * from table1 order by field(aaa,'') desc, aaa desc 위와같은 쿼리를 이용하면 table1의 aaa라는 필드에 값이 없는것이 먼저 출력되고, 그 뒤에는 높은값(?) 순으로 출력됩니다. 일반적으로 값이 없으면 우선순위가 뒤에오지만 이와같이 이용하면 원하는 정렬순서대로 정렬가능합니다. 이전 1 다음