Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/12/2023 in all areas

  1. You won't learn anything useful about SQL pursuing this design because the design is fundamentally flawed and directly opposed what SQL is designed to do. My answer is that you don't. I'm sure there is a way for it to be done, but doing so would teach you nothing useful. The correct solution to your problem is to re-design your table structure, then use SQL as it's intended to be used rather than fight against it trying to make a poor design work. This shows yet another potential reason why your design is flawed. Why do you have multiple rows for the same link? If the answer is "To have more than 4 key words" then that's wrong. The multi-table solution gives you the ability to have an unlimited number of keywords per link.
    1 point
  2. This was a mistake. If you find your self making multiple columns for the same type of data, what you really want is another table. A more proper change would have been to create a second link_keywords table with a reference to the link ID. Like so: links: id|domain|url|title link_keyword: link_id|keyword|points With that setup, your query would then be simple, like: select * from links inner join link_keyword on link_keyword.link_id=links.id where link_keyword.keyword = ? order by link_keyword.points desc If you want to have a global list of keywords and point values that is shared across all your links, then you'd have three tables, such as: links: id|domain|url|title link_keyword: link_id|keyword_id keywords: id|keyword|points The adjust the query with another join as appropriate.
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.