mysql - Select from one table and order by column of another table -


I am very new to MySQL and I could not find any solution for this problem. I appreciate all kind of help.

I have Table A and Table B, which are interconnected. I want to order a result from Table A. and order results by 'Date' column in Table B. This table is linked by 'user_id' My table is given below:

  Table A: ... name user_id (link to table b) Table B: user_id date  

Is it possible to do that? Thanks for any help!

You want to include an interior. Something like this:

  Außer_ID, A name, be it a sign in Join B from BUUSER_ID = AUser_ID WHERE (whatever is your filtering) ORDER BY B.date  

You should do some research on joining as it is an important and important thing for the development of the database (and knowing a good deal about it helps in building a good architecture).

The essence of this is that for every user_id in A, I want to find the matching user_id in B (due to the line INNER JOIN B at B.user_id = A.user_id). An internal insertion brings only in fairs, so if A has an ID of 2, but there are no 2 IDs in B, then it will not record (similar to record in B without record in A)

Now, the noticeable thing is that if I have a record with a user ID in 5, but there are two records in B with the User ID in 5, then in an internal investment There will be two records, each of the B. data in the data

Now, as your comment has been asked for this question, you want to get a higher rating, you want maximum function.

  Ausser_ID, b. Deat, Max (Britting) A Inner Join on On B User AID = AUser_ID WHERE (whatever your filtering is) by BDT by Group by Euser_ID, there are two parts, total work maximum () and statement by group. They work together so that for each unique Ears_ID, the database will bring back the highest recordings. You can also use functions like Min () which is the opposite, selection of berting, or calculation (which will calculate the record events, or yoga) that will add the records of that column. 

With database queries as always, play with them, make sure you get the right data back and you understand why when I create questions, I usually get from the table Selection begins with *, I understand what I should be involved, along with my records look fine, then restricting the columns and start filtering things Your benefit may vary on method, but To verify the data is always a good idea.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -