Big query!!!!!


#1

After running my programm I recieved a big query but it doesn’t work
Probably you can help me ,where a problems.Thanks.
This is a query:

select front., image_data.Type, image_data.ContentType, image_data.GUID, image_data.Size, image_data.Width, image_data.Height from image_info as front inner join image_data on front.image_id = image_data.image_info_id where front.Image_ID in (select front.image_id from image_info as front inner join image_data on front.image_id = image_data.image_info_id inner join photo_in_album on photo_in_album.Image_ID = front.Image_ID where photo_in_album.Album_ID = 1 AND image_data.type = 4 AND front.IsReverse = 0 union select reverse.image_id from image_info as front left outer join image_info as reverse on front.Reverse_Image_ID = reverse.Image_ID left outer join image_data on reverse.Image_ID = image_data.image_info_id left outer join photo_in_album on photo_in_album.Image_ID = front.Image_ID where photo_in_album.Album_ID = 1 AND image_data.type = 4 AND front.IsReverse = 0)) union select reverse., image_data.Type, image_data.ContentType, image_data.GUID, image_data.Size, image_data.Width, image_data.Height from image_info as front left outer join image_info as reverse on front.Reverse_Image_ID = reverse.Image_ID left outer join image_data on reverse.Image_ID = image_data.image_info_id where front.Image_ID in (select front.image_id from image_info as front inner join image_data on front.image_id = image_data.image_info_id inner join photo_in_album on photo_in_album.Image_ID = front.Image_ID where photo_in_album.Album_ID = 1 AND image_data.type = 4 AND front.IsReverse = 0 union select reverse.image_id from image_info as front left outer join image_info as reverse on front.Reverse_Image_ID = reverse.Image_ID left outer join image_data on reverse.Image_ID = image_data.image_info_id left outer join photo_in_album on photo_in_album.Image_ID = front.Image_ID where photo_in_album.Album_ID = 1 AND image_data.type = 4 AND front.IsReverse = 0));


#2

Start by identing your query and actually separate your joins and conditions.

Then use mysql_error() yo get a detailed error message.


#3

Psst - MySQL doesn’t support subqueries.

in (select

#4

Psst - It depends on the version of MySQL. 4.1 supports sub-queries. The user prob isn’t using 4.1, but they could if they need sub-query support. 4.1 is very stable from the projects I’ve tested with it.


#5

Try to simplify your query.