I am running the follwoing SQL query:
SELECT * FROM COUNTRIES WHERE USERTYPE = 'PREMIUM' ORDER BY SALES DESC;
The output of this query yields a list of countries.
Now I need to populate a field in another table which is like TOP_SALES_COUNTRY, SECOND_TOP_SALES_COUNTRY and THRID_TOP_SALES_COUNTRY for which I only need the first,second and third records in the output of this SELECT statement. Kindly advise on how this can be achieved.
SELECT ... LIMIT 3? You can't really collapse a 3 row result into a 3 column 1 row insert easily. but doing the limit query, fetching the results, then doing a 3-field insert would do the trick.