Jump to content

Recommended Posts

Hi, I'd love to hear your advice on this.

 

I have quite a few database tables which output data tables and use data from other tables. I'm currently stumped because I want to sort and order by certain columns which obtain their data via sql count queries. What is the desired approach?

 

Let's say I have a table full of hits, each with lots of details.

 

Then I have a table for categories.

 

I output my categories html table and in one of the columns is 'hits' which then counts the related hits in the hits table. But say I now want to order by hits?

 

Would it be ok for me to simply increment a column within the categories table called 'hits' thus making it simple to sort and order in the frontend.

Link to comment
https://forums.phpfreaks.com/topic/216929-any-advice-on-using-tickers/
Share on other sites

nogginj: You can definitely take that route, but you'd probably need to group by at least column user in the nested/sub query. You'd also need to either specify a where (WHERE user.user = hits.user), or join the 2 tables (user and hits)  in the subquery. Your statement as shown would return the same count of hits for each user. This value happens to be the total of records in table hits with a hits column value specificed. Not the right idea.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.