1

My Page has over 30mio Views per Day and i can't cache the Page (The data must always be up-to-date).

I have three MYSQL Queries which I would like to summarize. Is this possible?

SELECT * 
FROM  `meta_holdings` 
INNER JOIN coins ON coins.cmc_id = meta_holdings.cmc_id
WHERE  `userId` = $userId
LIMIT 0 , 999

SELECT * 
FROM  `meta_watchlist` 
INNER JOIN coins ON coins.cmc_id = meta_watchlist.cmc_id
WHERE  `userId` = $userId
LIMIT 0 , 999

SELECT * 
FROM  `coins` 
ORDER BY  `coins`.`rank` ASC 
LIMIT 0 , 30

Glad to have any help

3

3 Answers 3

1

A single query returns a single data set. By seeing your three queries, it looks like you need three data sets. You cannot achieve the same functionalities by mearging the queries. So the way it looks should be okay unless you have changed your requirements. Alternatively you can look into MySQL's internal cache.

Sign up to request clarification or add additional context in comments.

Comments

0

// Try this ..

SELECT * FROM  `meta_holdings` INNER JOIN coins ON coins.cmc_id = meta_holdings.cmc_id WHERE  `userId` = $userId LIMIT 0 , 999 
UNION
SELECT * FROM  `meta_watchlist` INNER JOIN coins ON coins.cmc_id = meta_watchlist.cmc_id WHERE  `userId` = $userId LIMIT 0 , 999
UNION
SELECT * FROM  `coins` ORDER BY  `coins`.`rank` ASC LIMIT 0 , 30

Comments

0

Here is the query if you are trying to find the top 30 rankings of coins table data of along with meta_holdings,meta_watchlist details -

SELECT * FROM  coins 
INNER JOIN meta_holdings ON coins.cmc_id = meta_holdings.cmc_id
INNER JOIN meta_watchlist ON coins.cmc_id = meta_watchlist.cmc_id
WHERE  meta_holdings.userId = $userId and meta_watchlist.userId = $userId
ORDER BY  `coins`.`rank` ASC 
LIMIT 0 , 30

1 Comment

#1054 - Unknown column 'holdings.userId' in 'where clause'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.