728x90
๋ฃจ์์ ์๋ผ ์ฐพ๊ธฐ
์ ๋ต
SELECT ANIMAL_ID, NAME, SEX_UPON_INTAKE
FROM ANIMAL_INS
WHERE NAME in ('Lucy','Ella','Pickle','Rogan','Sabrina','Mitty')
ORDER BY ANIMAL_ID
๊ด๋ จ ๋ด์ฉ
https://velog.io/@inyong_pang/MySQL-IN-%EC%A1%B0%EA%B1%B4
์ด๋ฆ์ el์ด ๋ค์ด๊ฐ๋ ๋๋ฌผ ์ฐพ๊ธฐ
์ ๋ต
SELECT ANIMAL_ID, NAME
FROM ANIMAL_INS
WHERE UPPER(NAME) like '%EL%' AND ANIMAL_TYPE = 'Dog'
ORDER BY NAME
๊ด๋ จ ๋ด์ฉ
SKIP
์ค์ฑํ ์ฌ๋ถ ํ์ ํ๊ธฐ
์ ๋ต
SELECT ANIMAL_ID, NAME,
IF(SEX_UPON_INTAKE like '%Neutered%' or
SEX_UPON_INTAKE like '%Spayed%', 'O', 'X') as '์ค์ฑํ'
FROM ANIMAL_INS
ORDER BY ANIMAL_ID
๊ด๋ จ ๋ด์ฉ
https://redcow77.tistory.com/260
์ค๋ ๊ธฐ๊ฐ ๋ณดํธํ ๋๋ฌผ(2)
์ ๋ต
SELECT OUTS.ANIMAL_ID, OUTS.NAME
FROM ANIMAL_OUTS OUTS
left join ANIMAL_INS INS on OUTS.ANIMAL_ID = INS.ANIMAL_ID
WHERE INS.DATETIME is not null
ORDER BY OUTS.DATETIME - INS.DATETIME DESC
LIMIT 2
๊ด๋ จ ๋ด์ฉ
SKIP
DATETIME์์ DATE๋ก ํ ๋ณํ
์ ๋ต
SELECT ANIMAL_ID, NAME, DATE_FORMAT(DATETIME, '%Y-%m-%d')
FROM ANIMAL_INS
ORDER BY ANIMAL_ID
๊ด๋ จ ๋ด์ฉ
SKIP
728x90