SQL

検索

or検索

SELECT *
FROM table_name
WHERE (col_name = 'aaa')
or (col_name = 'bbb')

in検索

SELECT *
FROM table_name
WHERE col_name IN (
'aaa',
'bbb'
)

検索結果に指定項目のみ表示

SELECT col_name1 , col_name2 , col_name3
FROM tb_sample
WHERE col_name IN (
'aaa'
'bbb')

重複行を除外(DISTINCT)

SELECT DISTINCT col_name FROM table_name

空白以外を検索

SELECT *
FROM table_name
WHERE col_name <> ''

範囲検索

WHERE col_name BETWEEN min AND max

範囲検索(範囲外)

WHERE col_name NOT BETWEEN min AND max

正規表現検索(REGEXP)

 WHERE col_name REGEXP '(text.*)';