fivestringsurf Posted March 24, 2011 Share Posted March 24, 2011 I'm tangled in this rather large query and not getting the results I need. I am expecting a set of results 100 items long. the statement I am having trouble with (I'm getting more than 100 results): SELECT class_item_id FROM class_custom WHERE name_abr >= (SELECT name_abr AS name_abr FROM class_custom WHERE class_item_id = 27 AND class_type_id = 122) AND name_abr < (SELECT name_abr +100 AS name_abr FROM class_custom WHERE class_item_id = 27 AND class_type_id = 122) AND class_type_id = 122 When I hardcode the inner query it works fine ( i get the expected 100 results): SELECT class_item_id FROM class_custom WHERE name_abr >= 300 AND name_abr < 400 AND class_type_id = 122 //works fine! -expected 100 results returned But here's where it gets weird...when I test each subquery individually they seem to return '300' and '400' respectively??? So I'm not sure where I have gone wrong here. SELECT name_abr AS name_abr FROM class_custom WHERE class_item_id = 27 AND class_type_id = 122 //returns 300 SELECT name_abr +100 AS name_abr FROM class_custom WHERE class_item_id = 27 AND class_type_id = 122 //returns 400 The peices seem to work individually, but not as a whole...Please advise, thank you Quote Link to comment https://forums.phpfreaks.com/topic/231612-inner-query-madness/ Share on other sites More sharing options...
fivestringsurf Posted March 24, 2011 Author Share Posted March 24, 2011 a breath of fresh air works wonders... I needed to type cast the result of the inner query. CAST( inner select stuff) AS UNSIGNED what happend to the "solved" button...I can't seem to find it anywhere Quote Link to comment https://forums.phpfreaks.com/topic/231612-inner-query-madness/#findComment-1191832 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.