I have a table that looks like this:
table name: uno
str_id | title
----------
"a1" | "hi"
"b2" | "bye"
"c3" | "etc."
table name: dos
str_id | other_col_name
-------------------------
"b2" | 1
"b2" | 5
"a1" | 6
"b2" | 7
I would like my query to look at the values in uno.str_id and then figure out an ordering of str_ids that have the most values in dos.str_id. I think I will need to join them on str_id and then order by count, but I am unsure how to do this in SQL syntax. Thanks for your time and help.
EDIT
the possible WHERE part must be put after the JOIN part (SQL syntax).
You MUST use aliases (or complete table name) if you’re querying on two tables with “same-named” fields, if you do anything with these common fields. In that query, Table uno is aliased as “u” and table dos is aliased as “d”. This mean, if you have a field title in uno and in dos, you have to write u.title to query on uno.title
version with aliases :
version without aliases (complete table name to avoid confusion for DBMS)