I have a MySql database round-about 2.5GB,
The table[A] has following columns, |anoid| |query| |date| |item-rank| |url|
I have just created another table[b] having columns only |query| and |date|
I want to insert all the distinct records in query column, with it's respective date, from Table[A] to [B], is there any fast query?
Use INSERT INTO ... SELECT:
INSERT INTO Tableb(query, date)
SELECT query, MAX(Date) AS MAXDate
FROM Tablea
GROUP BY query
This will give you distinct query with the most recent date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With