Skip to content
Advertisement

join tables from different databases only adding most recent date SQL

I am joining lots of data to handle dynamic/complex querying. The following is just a part of what I’m doing. I found a solution, then I think I tweaked it and lost it.

Database Structure:

oauth.users

order.orders ( I know bad naming, I didn’t create the database)

(customer_id = user.id)

I want to join only the most recent date

This is my query but something went wrong. Apologize Sql Isn’t my strong point, the results were multiple of the same users with different order dates were showing. If there were multiple of the most recent order_date then there would be multiple entries of that.

I’m using phpMyAdmin, and I think it uses Mysql / mariasql

Advertisement

Answer

You can do it like this

see example http://sqlfiddle.com/#!9/4c6bbca/12

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement