Heim  >  Fragen und Antworten  >  Hauptteil

mysql在限制条件下筛选某列数据相同的值?

有一个schema如下

fish(name,species,tankid)
eat(species1,species2)

其中eat表示鱼类之间相互捕食关系,species1是被捕食的鱼类tankid表示鱼缸id

需要筛选出:与可以捕食他的鱼(species2)放在同一个鱼缸中(tankid相等)的鱼(species1)的名字

求用sql语句说明

小白小白2767 Tage vor1792

Antworte allen(2)Ich werde antworten

  • 数据分析师

    数据分析师2017-10-01 01:07:01

    mysql在限制条件下筛选某列数据相同的值?-PHP中文网问答-mysql在限制条件下筛选某列数据相同的值?-PHP中文网问答

    围观一下哦,学习一下。

    Antwort
    0
  • 迷茫

    迷茫2017-03-23 09:18:36

    SELECT a.*, b.name AS name1, c.name AS name2
    FROM eat AS a 
    LEFT JOIN fish AS b ON a.species1=b.species
    LEFT JOIN fish AS c ON a.species2=c.species
    WHERE b.tankid=c.tankid

    Antwort
    1
  • StornierenAntwort