SQL query returning “Operand should contain 1 column(s)”

后端 未结 2 2000

I\'m currently working on a query which will have all rows from one table, but only limited information from the other.

I\'ve tried working with this query:



        
相关标签:
2条回答
  • 2021-01-26 05:13

    DISTINCT(p.id, p.firstname, p.lastname, p.company)

    is the problem. Drop the parenthesis:

    SELECT `t`.`uid`, `t`.`cid`, `t`.`id` FROM `tracking` as `t`
    JOIN (SELECT DISTINCT `p`.`id`, `p`.`firstname`, `p`.`lastname`, `p`.`company` FROM `publishers` as `p`) as `p`
    ON `p`.id = `t`.uid
    

    That should allow the query to work... however, if you have to use distinct for this, there might be something else wrong with your data structure or query.

    0 讨论(0)
  • 2021-01-26 05:23

    Surely no two publishers can share the same id, firstname, lastname, and company!!!

    SELECT t.uid
         , t.cid
         , t.id 
      FROM tracking t
      JOIN publishers p
        ON p.id = t.uid;
    
    0 讨论(0)
提交回复
热议问题