DEVILofDARKNESS Posted November 15, 2009 Share Posted November 15, 2009 I have this table(building_lvl): lvl | building_id | region_id And I want to get the region_id for which building_id=3 has lvl 2 and building_id=2 has lvl 5 Help with Code Tags PHP Syntax (Toggle Plain Text) SELECT * FROM building_lvl INNER JOIN regions ON regions.region_id = building_lvl.region_id WHERE ((building_lvl.building_id='3') && (building_lvl.lvl > 1)) && ((building_lvl.building_id='2') && (building_lvl.lvl > 4)) && (regions.nation_id = '17'); but this gives an empty set, why? (and I'm sure there is a region_id which has this conditions) Link to comment https://forums.phpfreaks.com/topic/181605-combining-two-rows-from-one-table/ Share on other sites More sharing options...
fenway Posted November 19, 2009 Share Posted November 19, 2009 I can't read that jumbled code. and besides, building_lvl.building_id can't be more than one thing at a time, so there is in fact NO SUCH region_id... and there never will be. You're mixing up logical and semantic boolean logic. Link to comment https://forums.phpfreaks.com/topic/181605-combining-two-rows-from-one-table/#findComment-960973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.