# MySQL_Table_Select

2016/05/04 16:20

1. Select field

``````select id, stuName, sex from t_student;
select * from t_student;`````` 2. Select + where

``````select * from t_student where id=7;
select * from t_student where age>22;`````` 3. Select + in

``````select * from t_student where age in (21, 23);
select * from t_student where age not in (21, 23);`````` 4. Select + between ... and ...

``````select * from t_student where age between 21 and 24;
select * from t_student where age not between 21 and 24;`````` 5. Select + like

``````select * from t_student where stuName like '张三';
select * from t_student where stuName like '张三%';
select * from t_student where stuName like '张三_';
select * from t_student where stuName like '%张三%';`````` ps: %: any word;

_: only one word;

6. Select + is null

``````select * from t_student where sex is null;
select * from t_student where sex is not null;`````` 7. Select + and

``select * from t_student where gradeName='一年级' and age=23;`` 8. Select + or

``select * from t_student where gradeName='一年级' or age=23;`` 9. Select + distinct

``select distinct gradeName from t_student;`` 10. Select + order by

``````select * from t_student order by age;
select * from t_student order by age asc;
select * from t_student order by age desc;`````` 11. Select + group by

``````select * from t_student group by gradeName;        /* Useless for only 'group by' */
/* group_concat */
/* Aggregate function: count() */
/* With having condition */
/* With rollup *`````` 12. Select + limit

``````select * from t_student limit 0, 5;
select * from t_student limit 5, 5;
select * from t_student limit 10, 5;`````` 1
0 收藏

### 作者的其它热门文章 0 评论
0 收藏
1
{"ft_lang_label":"__label__en","ft_lang_prob":0.7938767,"math_prob":0.51761717,"size":1871,"snap":"2020-45-2020-50","text_gpt3_token_len":509,"char_repetition_ratio":0.3422603,"word_repetition_ratio":0.2580645,"special_character_ratio":0.29663283,"punctuation_ratio":0.18624642,"nsfw_num_words":3,"has_unicode_error":false,"math_prob_llama3":0.99221206,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"im_url_duplicate_count":[null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,2,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-25T05:21:49Z\",\"WARC-Record-ID\":\"<urn:uuid:6fe57230-47c8-41ea-b9cb-45078bc9e068>\",\"Content-Length\":\"84931\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e1ec3c59-cf80-40c1-92ee-04aaaf10453a>\",\"WARC-Concurrent-To\":\"<urn:uuid:657ea815-924e-4897-9b91-d44ce42330af>\",\"WARC-IP-Address\":\"212.64.62.183\",\"WARC-Target-URI\":\"https://my.oschina.net/u/2363350/blog/669718\",\"WARC-Payload-Digest\":\"sha1:SQYFLVK37ZB6MDO2ZZTPSWHG4M5H7W5R\",\"WARC-Block-Digest\":\"sha1:LGEY7GDIJJ5WU6EDKGPLSZZGL4JHMHPN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107887810.47_warc_CC-MAIN-20201025041701-20201025071701-00186.warc.gz\"}"}