Raised This Month: $51 Target: $400
 12% 

SQL Foreign key ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 08-27-2018 , 15:24   SQL Foreign key ?
Reply With Quote #1

How to make more tables and use it with foreign key ?

If I create players table:

Code:
| id | steamid | xp | lvl | skills |
and skills table:

Code:
| player_id | skill_1 | skill_2 | skill_3 |
how to get each skill from players table ?
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-28-2018 , 09:28   Re: SQL Foreign key ?
Reply With Quote #2

This is a general SQL question, has nothing to do with AMXX. You will be better off searching forums and sites that are designated to SQL, as this is a rather basic question and you should be able to do it just by reading a few introductory tutorials on keys and joins.
__________________

Last edited by klippy; 08-28-2018 at 09:28.
klippy is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 08-28-2018 , 10:42   Re: SQL Foreign key ?
Reply With Quote #3

https://www.w3schools.com/sql/sql_join.asp
__________________
Airkish is offline
aditya12
New Member
Join Date: Feb 2019
Old 02-06-2019 , 21:33   Re: SQL Foreign key ?
Reply With Quote #4

https://www.welookups.com/sql/sql_join.html
aditya12 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-06-2019 , 21:47   Re: SQL Foreign key ?
Reply With Quote #5

Code:
SELECT skill_1, skill_2, skill_3

FROM tblPlayers

LEFT JOIN tblSkills
ON tblPlayers.id=tblSkills.player_id;
or
Code:
SELECT skill_1, skill_2, skill_3

FROM tblPlayers, tblSkills

WHERE tblPlayers.id=tblSkills.player_id;
__________________
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode