Jump to content

combining two rows from one table


DEVILofDARKNESS

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.