Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.