slushpuppie Posted February 20, 2009 Share Posted February 20, 2009 i have a query that is similar to this (only much more complex so i won't bother writing it out): SELECT `one`, `two`, (`three` + `four`) FROM `table` WHERE (`three` + `four`) < 25 is there a way i can set (`three` + `four`) to something, so that i can only reference it like: SELECT `one`, `two`, (`three` + `four`) AS `XXX` FROM `table` WHERE XXX < 25 (i know the above doesn't work, but i'm looking for something similar to it, where i can write out the equation once and then reference it). Link to comment https://forums.phpfreaks.com/topic/146165-looking-to-shorten-a-query-by-referencing-a-formula/ Share on other sites More sharing options...
Mchl Posted February 20, 2009 Share Posted February 20, 2009 Not really. Aliases are forbidden in WHERE clause, and there's no other means of doing it (AFAIK). You might however want to create a view with (`three` + `four`) being a separate column. Link to comment https://forums.phpfreaks.com/topic/146165-looking-to-shorten-a-query-by-referencing-a-formula/#findComment-767403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.