MySQL Forums
Forum List  »  General

Re: #1241 - Operand should contain 1 column(s)
Posted by: irek kordirko
Date: March 10, 2012 01:21PM

Please structure and indent your code, it really helps.
For example like this:
SELECT 	Libro.idLibro, 
	Libro.Libro, 
	Libro.Subtitulo, 
	Libro.Volumen, 
	Libro.Detalles, 
	Periodicidad.Periodicidad, 
	Genero.Genero, 
	Objeto_Editorial.Objeto_Editorial, 
	Opcion.Opcion AS Inedito, 
	(	
		SELECT 	Registro.idLibro, 
			Opcion.Opcion, 
			Original.Original, 
			Directorio.Directorio AS Registrante, 
			Organismo.Organismo, 
			Unidad.Unidad, 
			Registro.Ingreso, 
			Registro.Observaciones 
		FROM Registro 
		INNER JOIN Opcion ON Opcion.idOpcion=Registro.Protocolo 
		INNER JOIN Original ON Original.idOriginal=Registro.idOriginal 
		INNER JOIN Directorio ON Directorio.idDirectorio=Registro.Registrante 
		INNER JOIN Organismo ON Organismo.idOrganismo=Registro.idOrganismo 
		INNER JOIN Unidad ON Unidad.idUnidad=Registro.idUnidad

	) AS Detalle_Subcomite 
FROM Libro 
INNER JOIN Periodicidad ON Periodicidad.idPeriodicidad=Libro.idPeriodicidad 
INNER JOIN Genero ON Genero.idGenero=Libro.idGenero 
INNER JOIN Objeto_Editorial ON Objeto_Editorial.idObjeto_Editorial=Libro.idObjeto_Editorial 
INNER JOIN Opcion ON Opcion.idOpcion=Libro.idOpcion 
ORDER BY Libro ASC

If you are using a subquery in a SELECT statement in this way:
SELECT  field1,
        field2,
        ....
        (  subquery )
FROM table
....

the subquery must be a scalar subquery.
There are two restrictions the scalar subquery must satisfy:
1. The subquery must return exactly one column
2. The subquery must return not more than 1 row ( 0 or 1 row).


The subquery in your query returns 8 columns, and does not fulfill the first restriction - this is a reason of the error 1241.

Follow this link, it is described in documentation:
http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html



Edited 3 time(s). Last edit at 03/10/2012 01:28PM by irek kordirko.

Options: ReplyQuote


Subject
Written By
Posted
Re: #1241 - Operand should contain 1 column(s)
March 10, 2012 01:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.