首页 > 其他分享 >mp实现一个自连接查询

mp实现一个自连接查询

时间:2023-12-10 18:12:01浏览次数:19  
标签:指标值 查询 mainOrsub mp id indi 连接 indiinfor

起因是我设置了一个考核表结构,其中包含指标值,指标当前值,是主副指标等列。

后面我要进行考核的验收的时候,我发现验收要取得的是主当前指标值/主指标值以及副指标当前值/副指标值。如果想要让这两条数据一次都被查到,那么就需要进行自连接查询(查询同一个表两次,但是有些需要的输出内容要在一行数据中)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.mapper.IndiMapper">
    <resultMap id="mainIndi" type="com.example.entity.Indi">
        <result property="lastMainIndi" column="a.indi_true/a.indi"/>
        <result property="lastSubIndi" column="b.indi_true/b.indi"/>
        <result property="name" column="name"/>
        <result property="time" column="time"/>
        <result property="id" column="id"/>
    </resultMap>
    <select id="selectIndiShow" resultMap="mainIndi">
        SELECT a.id,a.name,a.time,a.indi_true/a.indi,b.indi_true/b.indi
        FROM indiinfor a ,indiinfor b
        WHERE a.mainOrsub=1 AND  b.mainOrsub=0
    </select>
</mapper>

这里很有趣的一点是,我一开始把column写成a.name,a.time,a.id,居然查不出数据。后来我在navicat上查询发现,查出来的结果有些就是不带表名的

 

标签:指标值,查询,mainOrsub,mp,id,indi,连接,indiinfor
From: https://www.cnblogs.com/kun1790051360/p/17893004.html

相关文章

  • 虚拟机突然连接不上xshell的解决方案
    今天我打开虚拟机和xshell的时候,发现我的node1连接不上xshell,但是node2、node3依旧可以链接,我在网上找了很多方法,但是是关于全部虚拟机连接不上xshell,但是,我只有一个连接不上,然后我发现我在虚拟机上输入ifconfig的时候显示它不显示我虚拟机的ip地址,查找后我发现是我的ens33这个......
  • numpy之003ndarray
    numpy常用的函数和属性 函数语法:numpy.array(object,dtype=None,copy=True,order='K',subok=False,ndmin=0)object:任何暴露数组接口方法的对象,通常是列表或元组。dtype:数组的所需数据类型,可选。copy:默认为True,意味着创建对象的副本。如果设置为False,则尝试使用原始对......
  • 20.Explain how the following reasoning fails to address the complexity of the is
    Round1:IdentifyingtheFailureinReasoningSpeaker1(StudentA):Hello,everyone!Let'skickoffourdiscussionbyexaminingthereasoning:"Sanyaiswarmallyearroundandhasbeautifulbeaches,soitisthebestplaceforavacation."......
  • ByteBuffer中的flip()、clear()、compact()
    publicstaticvoidmain(String[]args){try(FileChannelchannel=newFileInputStream("data.txt").getChannel()){//定义缓冲区allocate分配大小ByteBufferbuffer=ByteBuffer.allocate(10);while(true){......
  • numpy之002 优势
    对比通过⼀段代码运⾏来体会ndarray与Python原⽣list运算效率对⽐。importrandomimportnumpyasnpimporttime#创建包含随机数的列表a=[]foriinrange(1000000):#我减小了迭代次数以避免内存问题a.append(random.randint(1,100))#生成1到100之间的随......
  • C# 查询一个进程是否有管理员权限
    varhasElevated=false;varprocessName=Process.GetCurrentProcess().ProcessName;Process[]processes=Process.GetProcessesByName(processName);foreach(varprocessinprocesses){Console.WriteLine($......
  • 无涯教程-LINQ - SQL查询
    LINQtoSQL提供了用于将关系数据作为对象进行管理的基础结构(运行时)。它是.NETFramework3.5版的组件,可以将对象模型的语言集成查询转换为SQL,然后将这些查询发送到数据库以供执行。从数据库获取输出后,LINQtoSQL再次将其转换为对象。LINQtoSQL简介对于大多数ASP.NET开发......
  • Numpy之001 Numpy简介
    简介Numpy(NumericalPython)是⼀个开源的Python科学计算库,⽤于快速处理任意维度数组的工具。Numpy⽀持常⻅的数组和矩阵操作。对于同样的数值计算任务,使⽤Numpy⽐直接使⽤Python要简洁的多,性能好Numpy使⽤ndarray对象来处理多维数组,该对象是⼀个快速⽽灵活的⼤数据容器。 nda......
  • A sample of JSON RPC service
    ThisisasampleserviceprogramwhichshowhowtoimplementaJSONRPC.TheRPCserviceincludedtwofunctionswhichusedforRSAsignandverify.Ifyouwanttobuildthesourcecode,youneedinstallorbuildthreeopensorucelibraries:Libevent,cJSON......
  • CF300E Empire Strikes Back
    EmpireStrikesBackLuoguCF300E题目描述给定\(k\)个数\(a_1,a_2,\dots,a_k\),求一个数\(p=n!\)使得\(p\)能被\(\prod_{i=1}^ka_i!\)整除。\(a_i\le10^7,k\le10^6\)Solution考虑先对\(\displaystyle\prod\limits_{i=1}^ka_i!\)分解质因数。假设分解出来为\(\d......