saynotojava Posted January 22, 2016 Share Posted January 22, 2016 (edited) I have a table which currently contain data like Videoid,Tags,and clicks. As table Tags contain multiple tags, this causing problem where a same video will show a top clicked video on each tag section which it contain. What it should be,is how each tag have it's own clicks. At the moment solutions which i have but dont find it suitable are following: 1.To put a single tag instead list of tags, this is problem as then i would have to copy same data for every tag 2.To create another table called Clicks, and everytime when it is clicked on video in new tag, copy all relevant data from first table and then call UNION query. Problem with this how we also have duplicates(tho alteast not big as in first case, as new data is inserted only when click occur) and second is how same videos could show, as first it will show one which contain click stats and single tag, and then same video which dont contain click stats from first table. Closest to solution was using CROSS JOIN query, but problem with that query is how is simply pulling all data id by id, and it need to be linked, for example both tables have Videoid table which is same, and then order by Clicks which is in second table. Edited January 22, 2016 by saynotojava Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/ Share on other sites More sharing options...
Barand Posted January 22, 2016 Share Posted January 22, 2016 That's an interesting list of optional solutions but, having read it three times, I still no no idea of what you are trying to achieve. What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530239 Share on other sites More sharing options...
saynotojava Posted January 22, 2016 Author Share Posted January 22, 2016 Ok let me give entry example:Table Name: VideosVideoId - 12345Tags - Dogs,CatsClicks - 150So this is current table, where problem is when i order by Clicks, there will be same video showed on both tags(tags is same thing as categories). Video should have separate clicking statistic for each Tag listed in Tags, so there could be different videos listed when clicking on Tag ordered by clicks.I was thinking about removing Clicks from structure of table videos, then creating table called Clicks which will contain Videoid, Tag and Clicks.So Videoid should be same value as relevant videoid in table Videos, so we can know to which video entry is related clicking statistic.And here is example:Table name:clicksVideoid:12345Tag:DogsClicks:150Hopefully now is more clear.Can post more examples if needed. Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530244 Share on other sites More sharing options...
benanamen Posted January 22, 2016 Share Posted January 22, 2016 What you need to do is post a SQL dump of your DB so we can see what you actually have going on. If your DB structure is wrong there is no point addressing anything else until that is fixed and it may also solve whatever your problem is. Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530245 Share on other sites More sharing options...
Barand Posted January 22, 2016 Share Posted January 22, 2016 From what you have described you would want four tables (see attached model) video tag video_tag (to store the tags for each video) click (to log each click of a video's tag) Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530246 Share on other sites More sharing options...
saynotojava Posted January 22, 2016 Author Share Posted January 22, 2016 From what you have described you would want four tables (see attached model) video tag video_tag (to store the tags for each video) click (to log each click of a video's tag) But where is Tags in Video? That one is in list form (Dogs,Cats) and cannot be changed as it used already. That look fine if i would start with fresh table structure but i need to find solution to make it work with Tags in list form at table Video. Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530248 Share on other sites More sharing options...
Barand Posted January 22, 2016 Share Posted January 22, 2016 You started out acknowledging there was a problem with your current structure so I gave you a solution. Now you say you want to stick with that crap. problematic design and get someone to bail you out. Perhaps someone else will. 1 Quote Link to comment https://forums.phpfreaks.com/topic/300621-need-help-with-query/#findComment-1530250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.