Skip navigation links

MySQL Forums :: General :: #1241 - Operand should contain 1 column(s)


Advanced Search

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
#1241 - Operand should contain 1 column(s) Juan Vidal 03/07/2012 04:41PM
Re: #1241 - Operand should contain 1 column(s) irek kordirko 03/10/2012 01:21PM
Re: #1241 - Operand should contain 1 column(s) Rick James 03/12/2012 12:26AM
Re: #1241 - Operand should contain 1 column(s) Mr Cue 03/13/2012 09:31AM
Re: #1241 - Operand should contain 1 column(s) Mr Cue 03/13/2012 09:31AM
Re: #1241 - Operand should contain 1 column(s) Mr Cue 03/13/2012 09:26AM
Re: #1241 - Operand should contain 1 column(s) Mr Cue 03/13/2012 09:27AM


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.