mysql - How to SELECT value from one table based on same value's behavior in another table? -


Please help me with this ... If I have these tables and columns: TABLE1 Column with ID and TABLE2 with column FOO and bar , both of which have different IDs in which All also appear in the ID column TABLE1 .

I want to write a SELECT query to get all the IDs from ID to TABLE1 but for this condition Under:

For example, ID 101 will be selected from id if the number of rows ( X ) where ID appears under 101 FOO column TABLE2 , then divides by number of rows ( y ) End of column TABLE2 under the id 101 bar Gt appears, less the result of a certain value.

So if, say, X / Y , then the ID will be selected from the 101 query.

How does such a query look and how can it be done in a longer query?

Thank you!

You can connect together. From the table 2 where in the table (choose ID from 1 table ID) Group by AFU), q1, (SELECT Bar, COUNT (times) from wi table 2 where times (select from id from table 1) by group Bar) q2 WHERE q1.foo = q2 times and x / y and lt; 3

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -