Note that there are some explanatory texts on larger screens.

plurals
  1. POOperand should contain 1 column(s) but need a max(value) in subquery
    primarykey
    data
    text
    <p>i need to export a MySql Database to a SQLite database, im getting only the needed data from medias to make de SQLite database smaller as posible.</p> <p>I have a Query that give to me only the animalsMedias or the plantsMedias that are related to the entry with the last version, published and not filed of an animal or a plant.</p> <pre><code>SELECT AM.*, max(A.version) AS version FROM animalsMedias AS AM INNER JOIN animals AS A ON(AM.idAnimal = A.idAnimal AND A.filed = 0 AND A.published = 1) GROUP BY A.idLanguaje, A.idVersion; </code></pre> <p>And to get only the medias related i try to make a SELECT on "medias" table that only returns to me the medias that are related with the result of the previous select, so i put both in "IN()", but im getting the error:</p> <pre><code>#1241 - Operand should contain 1 column(s) </code></pre> <p>That is the query:</p> <pre><code>SELECT * from medias WHERE idMedia IN(SELECT AM.*, max(A.version) AS version FROM animalsMedias AS AM INNER JOIN animals AS A ON(AM.idAnimal = A.idAnimal AND A.filed = 0 AND A.published = 1) GROUP BY A.idLanguaje, A.idVersion) OR idMedia IN(SELECT PM.*, max(P.version) AS version FROM plantsMedias AS PM INNER JOIN plants AS P ON(PM.idPlant = P.idPlant AND P.filed = 0 AND P.published = 1) GROUP BY P.idLanguaje, P.idVersion); </code></pre> <p>How can i get the "max(A.version)" if i must use only 1 operand?, if i understood good, inside IN i must have only "IN(SELECT AM.idMedia FROM...." to be correct.</p> <p>Thanks in advice and sorry for my english, i try my best.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload