Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Eudemons Online > EO PServer Hosting > EO PServer Guides & Releases
You last visited: Today at 05:36

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Everything about SQL's ''Simple Guides'' .

Discussion on Everything about SQL's ''Simple Guides'' . within the EO PServer Guides & Releases forum part of the EO PServer Hosting category.

Reply
 
Old   #1
 
~Sword~Stalker~.'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 1,784
Received Thanks: 1,056
Everything about SQL's ''Simple Guides'' .

Database Tables

A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.
Below is an example of a table called "Persons":
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger The table above contains three records (one for each person) and five columns (P_Id, LastName, FirstName, Address, and City).
SQL Statements

Most of the actions you need to perform on a database are done with SQL statements.
The following SQL statement will select all the records in the "Persons" table:
SELECT * FROM Persons In this tutorial we will teach you all about the different SQL statements.
Keep in Mind That...

  • SQL is not case sensitive
Semicolon after SQL Statements?

Some database systems require a semicolon at the end of each SQL statement.
Semicolon is the standard way to separate each SQL statement in database systems that allow more than one SQL statement to be executed in the same call to the server.
We are using MS Access and SQL Server 2000 and we do not have to put a semicolon after each SQL statement, but some database programs force you to use it.
SQL DML and DDL

SQL can be divided into two parts: The Data Manipulation Language (DML) and the Data Definition Language (DDL).
The query and update commands form the DML part of SQL:
  • SELECT - extracts data from a database
  • UPDATE - updates data in a database
  • DELETE - deletes data from a database
  • INSERT INTO - inserts new data into a database
The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:
  • CREATE DATABASE - creates a new database
  • ALTER DATABASE - modifies a database
  • CREATE TABLE - creates a new table
  • ALTER TABLE - modifies a table
  • DROP TABLE - deletes a table
  • CREATE INDEX - creates an index (search key)
  • DROP INDEX - deletes an index

The SQL SELECT Statement

The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.
SQL SELECT Syntax

SELECT column_name(s)
FROM table_name and
SELECT * FROM table_name Note: SQL is not case sensitive. SELECT is the same as select.
An SQL SELECT Example

The "Persons" table:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select the content of the columns named "LastName" and "FirstName" from the table above.
We use the following SELECT statement:
SELECT LastName,FirstName FROM Persons The result-set will look like this:
LastName FirstName Hansen Ola Svendson Tove Pettersen Kari
SELECT * Example

Now we want to select all the columns from the "Persons" table.
We use the following SELECT statement:
SELECT * FROM Persons Tip: The asterisk (*) is a quick way of selecting all columns!
The result-set will look like this:


P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger


The SQL SELECT DISTINCT Statement

In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.
The DISTINCT keyword can be used to return only distinct (different) values.
SQL SELECT DISTINCT Syntax

SELECT DISTINCT column_name(s)
FROM table_name
SELECT DISTINCT Example

The "Persons" table:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select only the distinct values from the column named "City" from the table above.
We use the following SELECT statement:
SELECT DISTINCT City FROM Persons The result-set will look like this:
City Sandnes Stavanger

The WHERE Clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.
SQL WHERE Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value
WHERE Clause Example

The "Persons" table:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select only the persons living in the city "Sandnes" from the table above.
We use the following SELECT statement:
SELECT * FROM Persons
WHERE City='Sandnes' The result-set will look like this:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes
Quotes Around Text Fields

SQL uses single quotes around text values (most database systems will also accept double quotes).
Although, numeric values should not be enclosed in quotes.
For text values:
This is correct:

SELECT * FROM Persons WHERE FirstName='Tove'

This is wrong:

SELECT * FROM Persons WHERE FirstName=Tove For numeric values:
This is correct:

SELECT * FROM Persons WHERE Year=1965

This is wrong:

SELECT * FROM Persons WHERE Year='1965'
Operators Allowed in the WHERE Clause

With the WHERE clause, the following operators can be used:
Operator Description = Equal <> Not equal > Greater than < Less than >= Greater than or equal <= Less than or equal BETWEEN Between an inclusive range LIKE Search for a pattern IN If you know the exact value you want to return for at least one of the columns Note: In some versions of SQL the <> operator may be written as !=




The AND & OR Operators

The AND operator displays a record if both the first condition and the second condition is true.
The OR operator displays a record if either the first condition or the second condition is true.
AND Operator Example

The "Persons" table:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger Now we want to select only the persons with the first name equal to "Tove" AND the last name equal to "Svendson":
We use the following SELECT statement:
SELECT * FROM Persons
WHERE FirstName='Tove'
AND LastName='Svendson' The result-set will look like this:
P_Id LastName FirstName Address City 2 Svendson Tove Borgvn 23 Sandnes
OR Operator Example

Now we want to select only the persons with the first name equal to "Tove" OR the first name equal to "Ola":
We use the following SELECT statement:
SELECT * FROM Persons
WHERE FirstName='Tove'
OR FirstName='Ola' The result-set will look like this:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes
Combining AND & OR

You can also combine AND and OR (use parenthesis to form complex expressions).
Now we want to select only the persons with the last name equal to "Svendson" AND the first name equal to "Tove" OR to "Ola":
We use the following SELECT statement:
SELECT * FROM Persons WHERE
LastName='Svendson'
AND (FirstName='Tove' OR FirstName='Ola') The result-set will look like this:
P_Id LastName FirstName Address City 2 Svendson Tove Borgvn 23 Sandnes

The ORDER BY Keyword

The ORDER BY keyword is used to sort the result-set by a specified column.
The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.
SQL ORDER BY Syntax

SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC
ORDER BY Example

The "Persons" table:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger 4 Nilsen Tom Vingvn 23 Stavanger Now we want to select all the persons from the table above, however, we want to sort the persons by their last name.
We use the following SELECT statement:
SELECT * FROM Persons
ORDER BY LastName The result-set will look like this:
P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 4 Nilsen Tom Vingvn 23 Stavanger 3 Pettersen Kari Storgt 20 Stavanger 2 Svendson Tove Borgvn 23 Sandnes
ORDER BY DESC Example

Now we want to select all the persons from the table above, however, we want to sort the persons descending by their last name.
We use the following SELECT statement:
SELECT * FROM Persons
ORDER BY LastName DESC The result-set will look like this:
P_Id LastName FirstName Address City 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger 4 Nilsen Tom Vingvn 23 Stavanger 1 Hansen Ola Timoteivn 10 Sandnes

THE MOST IMPORTANT PART

The following table lists the most important built-in date functions in MySQL:
Function Description
NOW() Returns the current date and time
CURDATE() Returns the current date
CURTIME() Returns the current time
DATE() Extracts the date part of a date or date/time expression
EXTRACT() Returns a single part of a date/time
DATE_ADD() Adds a specified time interval to a date
DATE_SUB() Subtracts a specified time interval from a date
DATEDIFF() Returns the number of days between two dates
DATE_FORMAT() Displays date/time data in different formats

SQL Server Date Functions

The following table lists the most important built-in date functions in SQL Server:
Function Description
GETDATE() Returns the current date and time
DATEPART() Returns a single part of a date/time
DATEADD() Adds or subtracts a specified time interval from a date
DATEDIFF() Returns the time between two dates
CONVERT() Displays date/time data in different formats

SQL Date Data Types

MySQL comes with the following data types for storing a date or a date/time value in the database:

DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MM:SS
TIMESTAMP - format: YYYY-MM-DD HH:MM:SS
YEAR - format YYYY or YY

SQL Server comes with the following data types for storing a date or a date/time value in the database:

DATE - format YYYY-MM-DD
DATETIME - format: YYYY-MM-DD HH:MM:SS
SMALLDATETIME - format: YYYY-MM-DD HH:MM:SS
TIMESTAMP - format: a unique number

Note: The date types are chosen for a column when you create a new table in your database!

For an overview of all data types available, go to our complete Data Types reference.
SQL Working with Dates

Note You can compare two dates easily if there is no time component involved!

Assume we have the following "Orders" table:
OrderId ProductName OrderDate
1 Geitost 2008-11-11
2 Camembert Pierrot 2008-11-09
3 Mozzarella di Giovanni 2008-11-11
4 Mascarpone Fabioli 2008-10-29

Now we want to select the records with an OrderDate of "2008-11-11" from the table above.

We use the following SELECT statement:
SELECT * FROM Orders WHERE OrderDate='2008-11-11'

The result-set will look like this:
OrderId ProductName OrderDate
1 Geitost 2008-11-11
3 Mozzarella di Giovanni 2008-11-11

Now, assume that the "Orders" table looks like this (notice the time component in the "OrderDate" column):
OrderId ProductName OrderDate
1 Geitost 2008-11-11 13:23:44
2 Camembert Pierrot 2008-11-09 15:45:21
3 Mozzarella di Giovanni 2008-11-11 11:12:01
4 Mascarpone Fabioli 2008-10-29 14:56:59

If we use the same SELECT statement as above:
SELECT * FROM Orders WHERE OrderDate='2008-11-11'

we will get no result! This is because the query is looking only for dates with no time portion.

Tip: If you want to keep your queries simple and easy to maintain, do not allow time components in your dates!



-----------------
Conditional Statements

Very often when you write code, you want to perform different actions for different decisions.
You can use conditional statements in your code to do this.
In PHP we have the following conditional statements:
  • if statement - use this statement to execute some code only if a specified condition is true
  • if...else statement - use this statement to execute some code if a condition is true and another code if the condition is false
  • if...elseif....else statement - use this statement to select one of several blocks of code to be executed
  • switch statement - use this statement to select one of many blocks of code to be executed
The if Statement

Use the if statement to execute some code only if a specified condition is true.
Syntax

if (condition) code to be executed if condition is true; The following example will output "Have a nice weekend!" if the current day is Friday:
<html>
<body>

<?php
$d=date("D");
if ($d=="Fri") echo "Have a nice weekend!";
?>

</body>
</html> Notice that there is no ..else.. in this syntax. The code is executed only if the specified condition is true.
The if...else Statement

Use the if....else statement to execute some code if a condition is true and another code if a condition is false.
Syntax

if (condition)
code to be executed if condition is true;
else
code to be executed if condition is false; Example

The following example will output "Have a nice weekend!" if the current day is Friday, otherwise it will output "Have a nice day!":
<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>

</body>
</html> If more than one line should be executed if a condition is true/false, the lines should be enclosed within curly braces:
<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
{
echo "Hello!<br />";
echo "Have a nice weekend!";
echo "See you on Monday!";
}
?>

</body>
</html>
The if...elseif....else Statement

Use the if....elseif...else statement to select one of several blocks of code to be executed.
Syntax

if (condition)
code to be executed if condition is true;
elseif (condition)
code to be executed if condition is true;
else
code to be executed if condition is false; Example

The following example will output "Have a nice weekend!" if the current day is Friday, and "Have a nice Sunday!" if the current day is Sunday. Otherwise it will output "Have a nice day!":
<html>
<body>

<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>

</body>
</html>
~Sword~Stalker~. is offline  
Thanks
12 Users
Old 07/01/2011, 18:09   #2
 
Faith.'s Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 558
Received Thanks: 145
Awesome, heeh its like a copypaste from somewhere, but nice
Faith. is offline  
Thanks
2 Users
Old 07/02/2011, 03:31   #3
 
~Sword~Stalker~.'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 1,784
Received Thanks: 1,056
not all of them are copied . but i added all the info i got from my course and u should be thankfull heh . ill be editing for anything new i learn .

Regards
~Sword~Stalker~. is offline  
Thanks
1 User
Old 07/02/2011, 06:10   #4
 
Thorlon's Avatar
 
elite*gold: 100
Join Date: Mar 2011
Posts: 620
Received Thanks: 409
Thanks mate you have helped me learn new things
Thorlon is offline  
Thanks
1 User
Old 07/02/2011, 09:43   #5
 
~Sword~Stalker~.'s Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 1,784
Received Thanks: 1,056
a new part is added *

thanks and btw anyone wants anything related to SQL's please post it here .
~Sword~Stalker~. is offline  
Old 07/02/2011, 12:02   #6
 
elite*gold: 0
Join Date: Jan 2010
Posts: 43
Received Thanks: 6
Awesome Bro you are the best
yahyakhireldin is offline  
Old 07/03/2011, 08:57   #7
 
Marcus*'s Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 614
Received Thanks: 1,243
nice guide added to all things guide
Marcus* is offline  
Thanks
1 User
Old 07/03/2011, 11:14   #8
 
elite*gold: 0
Join Date: May 2010
Posts: 42
Received Thanks: 21
nice guide, thnx u have helped me in alot of ways. You are the best
karim21233 is offline  
Old 07/08/2011, 00:01   #9
 
wolfvb's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 238
Received Thanks: 217
WoW very good i have some books too i will but them now
the 1st
and the last one
in Arabic
the 2nd on in English
hope it can help
Attached Files
File Type: pdf SQL.pdf (130.3 KB, 34 views)
File Type: pdf SQL Command.pdf (835.6 KB, 27 views)
File Type: pdf SQL1.pdf (130.3 KB, 18 views)
wolfvb is offline  
Old 03/02/2013, 09:17   #10
 
lukmandzul's Avatar
 
elite*gold: 0
Join Date: Aug 2012
Posts: 67
Received Thanks: 49
can you give me recommends mysql version download link?

p/s : sorry or my bad english
lukmandzul is offline  
Old 04/25/2018, 23:24   #11
 
elite*gold: 0
Join Date: Sep 2007
Posts: 21
Received Thanks: 0
i know this is a bit late, but how do i add a username and password into mysql?
dante118 is offline  
Old 04/26/2018, 05:56   #12
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
Quote:
Originally Posted by dante118 View Post
i know this is a bit late, but how do i add a username and password into mysql?
change only YOUR_USERNAME and YOUR_PASSWORD, must be inside a '
Code:
INSERT INTO `account` SET `name` = 'YOUR_USERNAME', `password` = md5(concat('YOUR_PASSWORD',char(0xA3,0xAC,0xA1,0xA3),"fdjf,jkgfkl"));
run those query inside your mysql management software such as navicat

credit: @
PraDevil[ELITE] is offline  
Thanks
1 User
Old 04/26/2018, 06:13   #13
 
elite*gold: 0
Join Date: Sep 2007
Posts: 21
Received Thanks: 0
well i must have done something wrong in navicat got in the game fine, made my char a pm and then it wouldnt let me back in. im not worried about it anymore, i deleted the files, and i do thank you for helping me.

ill probably redownload the files again sometime later on to figure it out but i dont have time on my hands now to play on my own server. i just wanted to see if i can actually get it to work on localhost.
dante118 is offline  
Old 04/26/2018, 08:06   #14
 
PraDevil[ELITE]'s Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 1,486
Received Thanks: 919
Quote:
Originally Posted by dante118 View Post
well i must have done something wrong in navicat got in the game fine, made my char a pm and then it wouldnt let me back in. im not worried about it anymore, i deleted the files, and i do thank you for helping me.

ill probably redownload the files again sometime later on to figure it out but i dont have time on my hands now to play on my own server. i just wanted to see if i can actually get it to work on localhost.
most of the time this thing happened when trying to change the mysql password or add new user into it. im not sure why. happened to me once. but then i turn the mysql off and replace the mysql folder(in the same folder as 'my') and got it work again. OR

your character reach the level limit(255) but in cq_config the default max level was just around 130+ if i remember if you're using mannequin db. in cq_config search for (id = 10, type = 2001) change data1 to 255. make a backup first or you could try to open cq_user and set your character level around 130
PraDevil[ELITE] is offline  
Old 04/26/2018, 08:42   #15
 
elite*gold: 0
Join Date: Sep 2007
Posts: 21
Received Thanks: 0
well i saw revo db had characters past level 130 so i figured it would work but i guess not. ill have to redo everything over again, but i know the files in mannequin db like msgserver doesnt work, i replaced that with revo msgserver, i replaced a few files actually, and got everything working. but im not sure what i did wrong to get the login error when i changed the player level and such. ill have to do it another time when i have more free time.
dante118 is offline  
Reply


Similar Threads Similar Threads
91 .sql's zum einbatchen
07/23/2010 - General Coding - 1 Replies
huhu... Also,ich habe 91 .sql files die ich in mein Mysql Server einbatchen möchte normalerweise batche ich über Navicat ein aber damit kann man nur .sql nach .sql einbatchen und das dauert mir zu lange. Kennt jmd. ein weg mit dem ich die alle gleichzeitig einbatchen kann ?
Ultimatives Admin-GM-Paket (ID's, sql's, Addons)
03/03/2009 - WoW Private Server - 207 Replies
ACHTUNG! DIESE DATEIEN FUNKTIONIEREN NICHT MIT EINER NEUEN EMU-VERSION! Hallo Leute, aufgrund der meiner Meinung nach doch sehr großen Nachfrage nach allem möglichen Zeug für Ascent und Mangos-Server, habe ich mal ein kleines Paket zusammen gestellt, welches diesem Problem Abhilfe schaffen soll. :D Das Paket wurde aus Dateien erstellt, die von verschiedenen Autoren kommen, deshalb möchte ich mich hiermit bei allen bedanken, die ich in diesem Paket vergessen haben sollte zu erwähnen....



All times are GMT +1. The time now is 05:37.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.