Shadowing Posted August 26, 2012 Share Posted August 26, 2012 made a small example as simpliest as possible. I'm trying to do is only select the row if x is equal to $x but i have to do some math on some columns to see if its equal to little confusing hope someone knows what im trying to do $x = 2; Select id from travel where x = defender_x + defender_y "but only select it if its also equal to $x" Link to comment https://forums.phpfreaks.com/topic/267595-little-help-with-this-query/ Share on other sites More sharing options...
Christian F. Posted August 26, 2012 Share Posted August 26, 2012 It's quite easy, just add the second condition with AND between them. Like so: SELECT `id` FROM `travel` WHERE `x` = defender_x + defender_y AND `x` = $x Link to comment https://forums.phpfreaks.com/topic/267595-little-help-with-this-query/#findComment-1372564 Share on other sites More sharing options...
Shadowing Posted August 26, 2012 Author Share Posted August 26, 2012 lol oh ya haha wierd idk why i was making that more complicated then it needed to be haha Thanks ChristianF Link to comment https://forums.phpfreaks.com/topic/267595-little-help-with-this-query/#findComment-1372565 Share on other sites More sharing options...
Christian F. Posted August 26, 2012 Share Posted August 26, 2012 Hehe, some times we just need to think "Gloves". You're welcome, btw. Glad I could be of help. Link to comment https://forums.phpfreaks.com/topic/267595-little-help-with-this-query/#findComment-1372573 Share on other sites More sharing options...
Shadowing Posted August 26, 2012 Author Share Posted August 26, 2012 oh wait a sec i know whats going on now, the way i was doing it was correct. my example was incorrect i did this statement a week ago and looked at it now and thought it was wrong but it is correct if all those columns with the math is equal to the variable $travel3 = "SELECT defender_gbx FROM travel WHERE '".($session_x)."' = CEIL((attacker_gbx + ((defender_gbx - attacker_gbx) * ((UNIX_TIMESTAMP() - sent_time) / (arrived_time - sent_time)))) / 600) AND '".($session_y)."' = CEIL((attacker_gby + ((defender_gby - attacker_gby) * ((UNIX_TIMESTAMP() - sent_time) / (arrived_time - sent_time)))) / 450) AND stance <> 1 AND stance <> 5 AND stealth_tech <= '".($_SESSION['stealth'])."'"; Link to comment https://forums.phpfreaks.com/topic/267595-little-help-with-this-query/#findComment-1372575 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.