企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 标准查询 - 简单查询 ``` <pre class="calibre16">``` set names utf8<span class="token2">;</span> 设置编码 select <span class="token">*</span> from biao 基本查询 select distinct id from biao 结果字段不重复 select <span class="token">*</span> from biao order by id desc <span class="token2">,</span>time asc<span class="token2">;</span> 升序降序 select <span class="token">*</span> from biao group by sex having<span class="token2">;</span> 分组筛选 select <span class="token">*</span> from biao limit <span class="token3">4</span> 返回<span class="token3">4</span>条 select <span class="token">*</span> from biao <span class="token3">4</span><span class="token2">,</span><span class="token3">3</span> 返回<span class="token3">3</span>条<span class="token2">,</span>从第<span class="token3">5</span>条记录开始 select a<span class="token2">,</span>b<span class="token2">,</span>c from A inner join B on A<span class="token2">.</span>id <span class="token">=</span> B<span class="token2">.</span>id<span class="token2">;</span> 内连接 select a<span class="token2">,</span>b<span class="token2">,</span>c from A<span class="token2">,</span>B where A<span class="token2">.</span>id<span class="token">=</span>B<span class="token2">.</span>id<span class="token2">;</span>内连接 select <span class="token">*</span> from A left join B on A<span class="token2">.</span>id<span class="token">=</span>B<span class="token2">.</span>id<span class="token2">;</span> 左连接 select <span class="token">*</span> from A right join B on A<span class="token2">.</span>id<span class="token">=</span>B<span class="token2">.</span>id<span class="token2">;</span>右连接 select id from Table where id2 <span class="token5">in</span><span class="token2">(</span>select id3 from Table2<span class="token2">)</span> 子查询 select id from Table where <span class="token1">find_in_set</span><span class="token2">(</span>type<span class="token2">,</span><span class="token4">"ssq,sd,pls"</span><span class="token2">)</span> 查询分类 select id as ID from A as a 别名 select <span class="token">*</span> from A union all select <span class="token">*</span> from B 合并结果集 select <span class="token">*</span> from A union select <span class="token">*</span> from B 去重复 SELECT id<span class="token2">,</span>title FROM article WHERE id<span class="token"><</span>$id ORDER BY id desc LIMIT <span class="token3">1</span> 上一篇 SELECT id<span class="token2">,</span>title FROM article WHERE id<span class="token">></span>$id ORDER BY id ASC LIMIT <span class="token3">1</span> 下一篇 select <span class="token1">count</span><span class="token2">(</span>distinct openid<span class="token2">)</span> as total from TB 统计记录去重复 ``` ```