# MySQL

## 無primary key，取倒數資料

```
declare @a int
declare @sql varchar(5000)
set @a=(select count(*)-100 from t1)
set @sql=('select * from t1 where not f1 in (select top '+convert(varchar(10),@a)+' f1 from t1)')
exec(@sql)
```

參考資料:(<http://www.blueshop.com.tw/board/FUM20041006152735ZFS/BRD20071102082626MDZ/2.html>)

## 有primary

```
order by id desc
```

## Data type

bit 的資料 應該打成 b'101001'

## BLOB vs CLOB

BLOB -- BLOB CLOB -- TEXT

## 取得當前 MySQL 版本號

`SELECT version()`

`SELECT @@version`
