错误的SQL查询(初学者)

时间:2018-06-07 12:05:19

标签: mysql sql

我是SQL新手,我在Udemy独自学习。我遇到了很多问题,我正在努力解决其中一个问题:

此SQL查询有什么问题?

SELECT sport, count(*) 
FROM activities 
WHERE username IN ‘tony’
GROUP BY 1;

我有两个假设: 1 - 如果活动中的字段'sport'填充了字符串值,那么我们就不能使用count。 2 - 最后一个陈述应该是:

WHERE username in:‘tony’ GROUP BY 1;

我很乐意收到您对该问题的反馈并向您学习! 感谢

2 个答案:

答案 0 :(得分:5)

搜索IN将使用with()圆括号

display: inline-block;

答案 1 :(得分:1)

为tony添加括号, 例如:如果你想检查多个名字('tony','stark')

{

    const createDiv = clubs => {
    const $div = document.createElement(`div`);
    $div.classList.add(`club-info`);
    document.querySelector(`.clubs`).appendChild($div);

    const $club = document.createElement(`p`);
    $club.classList.add(`.clubname`);
    $club.textContent = `${clubs.name}`;

    const $origin = document.createElement(`p`);
    $origin.classList.add(`.origin`);
    $origin.textContent = `${clubs.origin}`;

    const $championships = document.createElement(`p`);
    $championships.classList.add(`.championships`);
    $championships.textContent = `${clubs.championships}`;


    document.querySelector(`.club-info`).appendChild($club);
    document.querySelector(`.club-info`).appendChild($origin);
    document.querySelector(`.club-info`).appendChild($championships);
  };

  const makeDivs = clubs => {
   clubs.forEach(club => {
      createDiv(club);
    });
};

const parse = clubs => {
  makeDivs(clubs);
};

  const init = () => {
    const url = `./assets/data/data.json`;

    fetch(url)
            .then(r => r.json())
            .then(json => parse(json.clubs));
  };
  init();

}