Phpmyadmin, how to link tables - mysql

Hello everyone this is my first question so if you miss something or if i am doing something wrong tell me!
I have two tables:
klanten:
id, ledenpagina_id
topics:
id, onderwerp, slogan, omschrijving
I want to add the ledenpagina_id to the topics table but I don't know how. I think it has something to do with Insert into but I looked up a few things but I cant get it to work in my case.
Please help me. :)

Related

SQL counting total by type

Hi everyone.
i have a question here that i was trying to practice on the web. however i do not know how write the MySQL query for this question. Can you please help me with this.
i keep getting errors in my codes. so far i only succeeded in concating the last name and first name together it seems.i do not know how to resolve the other parts of the questions
I hope you can help me with this

SQL Implementation - Social Media Like Functionality

I am building a full stack app, that is kind of like Pinterest or Instagram.
I've gotten stuck, which is a horrible feeling, and I'd love any help I could get from any kind soul out there! :)
So I'm trying to implement the "like" functionality. As y'all know, you can like an entity once, and only once. What I wonder is how to constrain the database in such a way that a user can't like more than once. The way I thought I'd do this is to have a separate Like table like this:
Now of course, if I UNIQUE the user_id, then users can only like one thing on the website, which obviously would be a disaster, hah. So my question is, how do I kind of make sure there are no duplicate rows with exactly the same information in them? Or make some kind of CHECK condition when creating the table so that there can't be more than one row where the user_id and the artpoem_id match?
Or am I thinking about this the wrong way? Should I have like a separate Like table for each and every ArtPoem-entry, and then UNIQUE the user_id?
I would be SO grateful for any help, as this has been bugging me for days. Thank you kindly!
Problem solved! If anyone else sees this in the future, here's how it happened:
With the help of #Solarflare here who pointed me in the right direction, I did this in my ORM (TypeOrm):
Which yielded this raw SQL:
And now my database gives me this error below when I try to add an additional like-table entry with matching artpoemIds and userIds, which is just what I was looking for! Yippie and onwards!

Database displays less records

I have a file with 4.300.000 records, but when I do SELECT COUNT(*) FROM 'mytable', It just displays 4.270.000. I don't know why is this happening, and I have no idea how to check what's going on. I've tried looking in Webmin, but I don't get it. Do you have any idea of how to see why is this failing?
Thank you and sorry for the bad English.

PhpmyAdmin do not display one table's data

Sorry if it sounds like a very basic question but I didn't find any thing like this in site and google couldn't show me the answer.
I have a table in my database that have this strucure :
And these indexes :
It seems some thing is wrong in this table because I can't SELECT data from this table, inside some PHP code and even in phpmyAdmin.
There was duplicated indexes in this and I did drop them but still I have problem with it.
I did OPTIMIZEd table but still can't select data.
When I click on the icon to show this table(general)table structure, it's fine or when I try to select another table in the database, it's cool, but this table(general) seems to be locked or do nor work correctly.
Do you know what's wrong and how fix this?
Thanks in Advance

Creating a SQL script to insert data into a table (MySQL)

I sincerely apologize if this sounds like the most ridiculously beginner question, but I'm just starting to figure out SQL. It's more out of necessity than learning from the ground up. Thankyou for any help though, I sincerely appreciate it!
What I'm trying to do is create a script to insert data to the following table:
playercreateinfo_item.sql - github link to copy of the sql table
The fields/columns are race, class, itemid, amount.
How would I go about creating a script for this? From my basic understanding, it would be something like:
INSERT INTO playercreateinfo_item (race,class,itemid,amount)
VALUES (1,1,1,1);
But what else would I need? Like a header or footer? I'm honestly not even sure what a full script would look like for this! I also have to insert hundreds of different pieces of data, I'm not sure if there's an easy way to do it, or if I have to just do it manually. I'm so sorry if this is a horribly basic question, I'm just lost trying to learn. Thankyou so much in advance for any help! You guys are fantastic.
A SQL script is just a text file with SQL commands. Usually queries are separated with a semicolon.
No header or footer required.
Edit:
In case of inserting multiple tuples, you can do a batch insert with INSERT like this
INSERT INTO playercreateinfo_item (race,class,itemid,amount)
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3);