ueon Posted September 13, 2011 Share Posted September 13, 2011 I hired someone to do a project, and I need to alter his query a bit but have no idea what it says : $query = "select a.*,b.Username,b.EmailAddress,b.UserID from status a inner join users b on(a.email=b.EmailAddress) where a.email in($searchuser) order by id desc "; Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted September 13, 2011 Share Posted September 13, 2011 query selects every field from table a.. which is what a.* means the fields Username,EmailAddress,UserID from table b.. now the programmer aliases table status to be "a" and users to be "b", for a shorter query.. the tables are joined on the condition that the email field from the "status" table equals the Emailaddress field from table "users" now the main query has a WHERE clause here it will grab rows where the value from field "email" from table "status" is in the array $searchuser.. it orders the results by id descending.. Quote Link to comment Share on other sites More sharing options...
ueon Posted September 13, 2011 Author Share Posted September 13, 2011 thanks aykay, but what does the ON and IN mean? Quote Link to comment Share on other sites More sharing options...
AyKay47 Posted September 13, 2011 Share Posted September 13, 2011 the ON is used in JOIN queries... and specifies how the two queries are joined, what the conditions need to be in order for the tables to join.. IN is a MYSQL function that searches an array of values for the specified value... documentation and examples can be found at these two links http://dev.mysql.com/doc/refman/5.0/en/join.html http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.