Jump to content

Recommended Posts

Posted (edited)
Hi!

 

Since all the SQL tutorials here seem to be very much outdated (non existent). I wanted to write a tutorial on how to write basic SQL statements. SQL is a VERY complex and nasty language, there's so much more to know than I can cover in a simple tutorial, but I will try my best.

 

I will start with a tutorial about selecting data, but if you guys want me to make more for updating, deleting, creating, subqueries, counting, summing or whatever, tell me. 

 

Let's say we own a website which has users and these users can all update their profile with a certain country. Our tables look like this:

 

user

id country_id name

1 1 Example Name1

2 1 Example Name2

3 2 Example Name3

4 2 Example Name4

5 NULL Example Name5

 

country

id name

1 Australia

2 Germany

3 China

 

The most basic select statement looks like this:

 



SELECT columnname, columnname, columnname FROM tablename;


  

Let’s say we want to select the name and the id of all users, we would write it like this:

 



SELECT id, name FROM user;


  

This will return the name and id of ALL the records. It will look like this:

id name

1 Example Name1

2 Example Name2

3 Example Name3

4 Example Name4

5 Example Name5

 

But what if we only want to know the name and id from the users who live in Australia? We first need to look in our country table and we see that Australia has id 1. Now we have to add a ‘WHERE’ statement to our SELECT. The most basic SELECT WHERE statement looks like this:

 



SELECT columnname, columname, columnname FROM tablename WHERE columname = 'value' OR columname = 'value' AND columnname = 'value';


  

As you can see, you can add ORs and ANDs to your statement, this works just like you would expect it to work. If you are a programmer, you can see OR as || and AND as &&.

 

Now let’s select our Australian users:



SELECT id, name FROM user WHERE country_id = 1;


  

This will return only Australian users. It will look like this:

id name

1 Example Name1

2 Example Name2

 

But what if we want to select id, name and country name? How do we do that? We can do that with a JOIN. There are a lot of different joins; INNER JOIN, OUTER JOIN, RIGHT JOIN, LEFT JOIN, RIGHT OUTER JOIN, etc.

 

This is a lot of information to take in at once, so we’ll keep it simple and narrow this guide down to two JOINs: the LEFT JOIN and the INNER JOIN. 

So what is the difference? I’ll show you this in the following examples, since writing it down is difficult.

 

The most basic JOIN looks like this:



SELECT tablename1.columnname , tablename1.columname, tablename2.columname FROM tablename1
JOIN tablename2 ON tablename2.keycolumn1 = tablename1.keycolumn2;


  

The key columns represent a column belonging to table2 which is also present in table1.

Now to ALSO select the country name for all users, we write our SELECT statement like this:

 



SELECT user.id, user.name, country.name FROM user
LEFT JOIN country ON country.id = user.country_id;


 

We can add some aliases to make our query a bit more readable:

 



SELECT u.id, u.name, c.name FROM user u
LEFT JOIN country c ON c.id = u.country_id;


 

Using aliases is NOT a must, it just comes down to a matter of preference whether you want to use it or not. 

 

However if you are selecting two columns with the same column name, in our example this is u.name and c.name, you have to add an alias to one of them. I would do it like this:

 



SELECT u.id, u.name, c.name country_name FROM user u
LEFT JOIN country c ON c.id = u.country_id;


  

This query will return the following:

id name country_name

1 Example Name1 Australia

2 Example Name2 Australia

3 Example Name3 Germany

4 Example Name4 Germany

5 Example Name5 NULL

 

But wait.. Example Name5 hasn’t got a country_id filled in, what if we only want users who do have a country_id? This is where the INNER JOIN comes in handy, it will remove all those NULL records from the query result.

 

We use the exact same query and only change LEFT JOIN to INNER JOIN, which will look like:



SELECT u.id, u.name, c.name country_name FROM user u
INNER JOIN country c ON c.id = u.country_id;


  

Now our result is:

id name country_name

1 Example Name1 Australia

2 Example Name2 Australia

3 Example Name3 Germany

4 Example Name4 Germany

 

Thanks.

 

PS: I dont own this guide, i copied it from a pdf file to share it with people keep in mind and thanks again.

Edited by Sawadee
  • Downvote 1
Posted

Nice beginner guide! :)

Btw, you should use parentheses in WHERE columname = 'value' OR columname = 'value' AND columnname = 'value'...

Posted

Nice beginner guide! :)

Btw, you should use parentheses in WHERE columname = 'value' OR columname = 'value' AND columnname = 'value'...

 

 

just made my exams from it so at start i can offer for free and see more in future

 

I will fix it thanks for the tip brother :) 

 

It could be nice to see people helpin each other on Lineage2 Section actually thats what this community needs.

Posted

-1 reputation due to copy paste without proper credits. I was going to give you +1 but then elfo happened. 

Is fine if you copy paste, everyone does it. But at least give credits even if is 5 lines or 4 lines. 

 

If you sit down and make a better and bigger tutorial with more examples such as if i want to find ID of a monster that type is not equal to X 

i'll give you again +

Posted (edited)

 

 

-1 reputation due to copy paste without proper credits. I was going to give you +1 but then elfo happened. 

Is fine if you copy paste, everyone does it. But at least give credits even if is 5 lines or 4 lines. 

 

If you sit down and make a better and bigger tutorial with more examples such as if i want to find ID of a monster that type is not equal to X 

i'll give you again +

 

I didnt copied anything from RageZone, and i simply wanted to share this guide from a tutorial guide.pdf that i have on my pc, So do i have to give credits to my Pdf? i dont care about reputations but explain me why do you butthurt some much and instead of doin actually something you just trashtalkin other topics and posts? and please dont start tellin me that This my opinion and im free to say anythin, if you wanna say anythin u want just go on spam topics or make a guide share it with people and dont expect anythin.

Edited by Sawadee
Posted

I didnt copied anything from RageZone, and i simply wanted to share this guide from a tutorial guide.pdf that i have on my pc, So do i have to give credits to my Pdf? i dont care about reputations but explain me why do you butthurt some much and instead of doin actually something you just trashtalkin other topics and posts? and please dont start tellin me that This my opinion and im free to say anythin, if you wanna say anythin u want just go on spam topics or make a guide share it with people and dont expect anythin.

 

Lel, i made the biggest guide since 2012 about l2j gathered 100k views +

Also now you're being bitch so you deserve -1 and xdem's laugh. 

Posted (edited)

He even c/p "Hi" just promote this autist already

 

Lel, i made the biggest guide since 2012 about l2j gathered 100k views +

Also now you're being bitch so you deserve -1 and xdem's laugh. 

 

I wont argue with people like you, once i did while u wasnt even registered on mxc. U are free to post anythin you want im not gonna feed some random trolls :) NM2YaH5.png

Edited by Sawadee
Posted (edited)

i have on my pc, So do i have to give credits to my Pdf? 

Oh... and you 'PDF' is saying :

 

I will start with a tutorial about selecting data, but if you guys want me to make more for updating,

 

You want ur pdf make updates? :D

 Its cool bro :D

Edited by melron

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • LIVE VERIFICATION? SUMSUB? “IMPOSSIBLE”? ▪ Spoiler: it is possible — if you know who to work with. A client came in with a task to pass **live verification** on **WantToPay**, a Telegram virtual card service. On the platform side — **Sumsub**: liveness check, SMS, manual review. “Fast” and “by eye” simply don’t work here. › What was done: → analyzed the verification scenario and Sumsub requirements → built the correct flow: phone number, email, timing → **completed live verification remotely, without account handover** → handled SMS and confirmation codes → brought the process to final approval ▪ Result: → verification passed → access granted → no flags or repeat requests ▪ Live verification is not luck. It’s scenario-based preparation — not hope. › TG: @mustang_service ( https:// t.me/ mustang_service ) › Channel: Mustang Service ( https:// t.me/ +6RAKokIn5ItmYjEx ) *All data is published with the client’s consent.* #verification #sumsub #livecheck #kyc #case
    • IMPORTANT INFO: In a few days, I will switch to completely new code, written from scratch with a new download system, patch building and management system. The Updater will become true 2026 code with "foolproof systems". I'm going to create a Discord server for customers to request new ideas and features. FIRST CUSTOMERS ARE ALREADY USING THE NEW UPDATER ON LIVE SERVERS! Watch this topic for upcoming info because the new updater is around the corner! Yes, you can still use self-update on the previous updater! No, the new updater won't be compatible with the old patch system! A new build is required, but players who already have game files won't have to download the entire patch again! New templates and updates to existing templates are coming soon! Sneak peek:  
    • i used guytis IL project and source. i found in his project there are 3 Client version source... 1,CliExt_H5   --->this one cant be compiled in VS2005,i did know why..is it for H5 client? 2,CliExtNew  --->this one is IL version ,but when i compiled it and use it.player cant login game,MD5Checksum wrong.i check the source code,but not found any hints. 3,L2Server    --->this one for HB client?im not sure...   so my question is what are the differences between these three versions of cliext.dll?how can i fix the issue of the MD5Checksum not matching problem?   01/29/2026 21:04:11.366, [CCliExt::HandleCheckSum] Invalid Checksum[1130415144] vs [-721420287] packet[dd] len[29] sum[2698] key[30] HWID[] Account[]! 01/29/2026 21:04:11.366, SocketLimiter::UserSocketBadunknownprotocol 11111111111 01/29/2026 21:04:11.366, [usersocket]unknown protocol from ip[113.137.149.115]!      
    • ## [1.4.1] - 2026-01-29   ### ✨ New Features - **Short Description**: Server owners can add a short tagline (up to 240 characters) on the server info page, under the "Online" status. It appears in the server list (By Votes) for VIP, Gold VIP, and Pinned servers so players see a brief summary at a glance.   ### 🔄 Improvements - **Server Info Page**: Description field is limited to 3000 characters with a character counter; the textarea is vertically resizable. A second **Save Changes** button was added at the bottom (after the description) for easier saving. - **Server Name**: In My Servers → Edit, the server name is read-only and can no longer be changed (avoids accidental changes and naming conflicts). - **Server Rows (By Votes)**: Short descriptions wrap correctly and no longer affect row height; long text is clipped to two lines so the list stays tidy and consistent.   ---
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and 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..