http://dev.mysql.com/downloads/mysql/4.1.html

check for glic
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-server-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-bench-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-client-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-devel-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-shared-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-embedded-4.1.21-0.i386.rpm
http://mysql.mirrors.pair.com/Downloads/MySQL-4.1/MySQL-shared-compat-4.1.21-1.i386.rpm

or

162 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-server-4.1.21-0.i386.rpm
163 ls
164 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-bench-4.1.21-0.i386.rpm
165 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-client-4.1.21-0.i386.rpm
166 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-devel-4.1.21-0.i386.rpm
167 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-shared-4.1.21-0.i386.rpm
168 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-embedded-4.1.21-0.i386.rpm
169 wget http://mysql.rediris.es/Downloads/MySQL-4.1/MySQL-shared-compat-4.1.21-0.i386.rpm

1. Become the superuser if you are working in your account. (Type "su" and the prompt and give the root password).
2. Change to the directory that has the RPM download.
3. Type the following command at the prompt:

rpm -ivh "mysql_file_name.rpm"

Similarly you can also install the MySQL client and MySQL development RPMs if you've downloaded them.
Alternatively, you can install the RPMs through GnoRPM (found under System).
4. Now we'll set a password for the root user. Issue the following at the prompt.

mysqladmin -u root password mysqldata

where mysqldata is the password for the root. (Change this to anything you like).
5. It is now time to test the programs. Typing the following at the prompt starts the mysql client program.

mysql -u root -p

The system asks for the the password. Type the root password (mysqldata).
If you don't get the prompt for password, it might be because MySQL Server is not running. To start the server, change t
o /etc/rc.d/init.d/ directory and issue the command ./mysql start (or mysql start depending on the value of the PATH variable
on your system). Now invoke mysql client program.
6. Once MySQL client is running, you should get the mysql> prompt. Type the
following at this prompt.:

show databases;

7. You should now get a display similar to:

+----------------+ | Database | +----------------+ | mysql | |
test | +----------------+ 2 rows in set (0.00 sec)

Okay, we've successfully installed MySQL on your system. Now let's look at some
MySQL basics.

 

The MySQL database package consists of the following:
* The MySQL server: This is the heart of MySQL. You can consider it a program that stores and manages your databases.
* MySQL client programs: MySQL comes with many client programs. The one with which we'll be dealing a lot is called mysql
(note: smallcaps). This provides an interface through which you can issue SQL statements and have the results displayed.
* MySQL client Library: This can help you in writing client programs in C. (We won't be taking about this in our tutor

 

The difference between MySQL and mysql
MySQL is used to refer to the entire MySQL distribution package or the MySQL server, while mysql refers to a client program.

Why have client and server programs?
The server and client programs are different entities. Thus, you can use client programs on your system to access data on a My
SQL server running on another computer. (Note: you would need appropriate permissions for this. Consult the system administrat
or of the remote machine.)
Dividing the package into a server and clients separates the actual data from the interface.

 

# I assume that you are working from your account and not the root. Start a terminal session and become the superuser (Type su
at the prompt and then enter the root password).
# Now we'll access the MySQL server. Type:

mysql -u root -p

The system prompts for the MySQL root password that you set up in Installing MySQL on Linux. (Note: This is not the Linux root password but the MySQL root password). Enter the password, which is not displayed for security reasons.
Once you are successfully logged in, the system prints a welcome message and displays the mysql prompt ... something like

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.22.32

Type 'help' for help.

mysql>

 

 

Now we are ready for creating the employees database. Issue the command:

create database employees;

(Note: The command ends with a semi-colon)

 

# An important point to note is that this database is created by the root and so will not be accessible to any other user unle
ss permitted by the root. Thus, in order to use this database from my account (called manish), I have to set the permissions b
y issuing the following command:

GRANT ALL ON employees.* TO manish@localhost IDENTIFIED BY "eagle"

The above command grants my account (manish@localhost) all the permissions on employees database and sets my password to eagle
. You should replace manish with your user name and choose an appropriate password.
# Close the mysql session by typing quit at the prompt. Exit from superuser and come back to your account. (Type exit).

 

 

To connect to MySQL from your account, type:

mysql -u user_name -p

Type in the password when prompted. (This password was set by the GRANTS ALL... command above) . The system displays the welco
me message once you have successfully logged on to MySQL. Here is how your session should look like:
[manish@localhost manish]$ mysql -u manish -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 3.22.32

Type 'help' for help.

mysql>

# Typing the command SHOW DATABASES; will list all the databases available on the system. You should get a display similar to:

mysql> SHOW DATABASES;
+----------------+
| Database |
+----------------+
| employees |
| mysql |
| test |
+----------------+
3 rows in set (0.00 sec)

# Enter quit at the mysql> prompt to come out of the mysql client program.

 

Databases store data in tables. So what are these tables?
In simplest terms, tables consist of rows and columns. Each column defines data of a particular type. Rows contain individual
records.
Consider the following:

Name Age Country Email
Manish Sharma 28 India manish@simplygraphix.com
John Doe 32 Australia j.dow@nowhere.com
John Wayne 48 U.S.A. jw@oldwesterns.com
Alexander 19 Greece alex@conqueror.com

The table above contains four columns that store the name, age, country and email. Each row contains data for one individual.
This is called a record. To find the country and email of Alexander, you'd first pick the name from the first column and and t
hen look in the third and fourth columns of the same row.

A database can have many tables; it is tables, that contain the actual data. Hence, we can segregate related (or unrelated) data in different tables. For our employees database we'll have one table that stores company details of the employees. The othe
r table would contain personal information. Let's make the first table.

The SQL command for creating tables looks complex when you view it for the first time. Don't worry if you get confused, we'll
be discussing this in more detail in later sessions.

CREATE TABLE employee_data
(
emp_id int unsigned not null auto_increment primary key,
f_name varchar(20),
l_name varchar(20),
title varchar(30),
age int,
yos int,
salary int,
perks int,
email varchar(60)
);

 

Note: In MySQL, commands and column names are not case-sensitive; however, table and database names might be sensitive to case
depending on the platform (as in Linux). You can thus, use create table instead of CREATE TABLE.
The CREATE TABLE keywords are followed by the name of the table we want to create, employee_data. Each line inside the parenth
esis represents one column. These columns store the employee id, first name, last name, title, age, years of service with the
company, salary, perks and emails of our employees and are given descriptive names emp_id, f_name, l_name, title, age, yos, sa
lary, perks and email, respectively.
Each column name is followed by the column type. Column types define the type of data the column is set to contain. In our exa
mple, columns, f_name, l_name, title and email would contain small text strings, so we set the column type to varchar, which m
eans varriable characters. The maximum number of characters for varchar columns is specified by a number enclosed in parenthes
is immediately following the column name. Columns age, yos, salary and perks would contain numbers (integers), so we set the c
olumn type to int.
Our first column (emp_id) contains an employee id. Its column type looks really mean, yeh?. Let's break it down.
int: specifies that the column type is an integer (a number).
unsigned: determines that the number will be unsigned (positive integer).
not null: specifies that the value cannot be null (empty); that is, each row in the column would have a value.
auto_increment: When MySQl comes across a column with an auto_increment attribute, it generates a new value that is one greate
r than the largest value in the column. Thus, we don't need to supply values for this column, MySQL generates it for us! Also,
it follows that each value in this column would be unique. (We'll discuss the benefits of having unique values very shortly).
primary key: helps in indexing the column that help in faster searches. Each value has to be unique.

Why have a column with unique values?
Our company Bignet has grown tremendously over the past two years. We've recruited thousands. Don't you think there is a fair
chance that two employees might have the same name? Now, when that happens, how can we distinguish the records of these two em
ployees unless we give them unique identification numbers? If we have a column with unique values, we can easily distinguish t
he two records. The best way to assign unique numbers is to let MySQL do it!

 

Using a database
We've already created our employees database. Now let's start the mysql client program and select our database. Once at the my
sql prompt, issue the command:

SELECT DATABASE();

The system responds with

mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| |
+------------+
1 row in set (0.01 sec)

 

 

The above shows that no database has been selected. Actually, everytime we work with mysql client, we have to specify which da
tabase we plan to use. There are several ways of doing it.

Specifying the database name at the start; type the folowing at the system prompt:
mysql employees (under Windows)
mysql employees -u manish -p (under Linux)

Specifying the database with the USE statement at the mysql prompt:
mysql>USE employees;

Specifying the database with \u at the mysql prompt:
mysql>\u employees;
It's necessary to specify the database we plan to use, else MySQL will throw an error.

 

 

Creating tables

Once you've selected the employees database, issue the CREATE TABLE command at the mysql prompt.

CREATE TABLE employee_data
(
emp_id int unsigned not null auto_increment primary key,
f_name varchar(20),
l_name varchar(20),
title varchar(30),
age int,
yos int,
salary int,
perks int,
email varchar(60)
);

Note: When you press the enter key after typing the first line, the mysql prompt changes to a ->. This means that mysql unders
tands that the command is not complete and prompts you for additional statements. Remember, each mysql command ends with a sem
i-colon and each column declaration is separated by a comma. Also, you can type the entire command on one line if you so want.
You screen should look similar to:

 

mysql> CREATE TABLE employee_data
-> (
-> emp_id int unsigned not null auto_increment primary key,
-> f_name varchar(20),
-> l_name varchar(20),
-> title varchar(30),
-> age int,
-> yos int,
-> salary int,
-> perks int,
-> email varchar(60)
-> );
Query OK, 0 rows affected (0.01 sec)

Okay, we just made our first table.

 

Now that we've created our employee_data table, let's check its listing.
Type SHOW TABLES; at the mysql prompt. This should present you with the following display:

mysql> SHOW TABLES;
+---------------------+
| Tables in employees |
+---------------------+
| employee_data |
+---------------------+
1 row in set (0.00 sec)

 

Describing tables
MySQL provides up with a command that displays the column details of the tables.
Issue the following command at the mysql prompt:

DESCRIBE employee_data;

The display would be as follows:

mysql> DESCRIBE employee_data;
+--------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+----------------+
| emp_id | int(10) unsigned | | PRI | 0 | auto_increment |
| f_name | varchar(20) | YES | | NULL | |
| l_name | varchar(20) | YES | | NULL | |
| title | varchar(30) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| yos | int(11) | YES | | NULL | |
| salary | int(11) | YES | | NULL | |
| perks | int(11) | YES | | NULL | |
| email | varchar(60) | YES | | NULL | |
+--------+------------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

DESCRIBE lists all the column names along with their column types of the table.
Now let's see how we can insert data into our table.

 

Inserting data into tables
The INSERT SQL statement impregnates our table with data. Here is a general form of INSERT.

INSERT into table_name (column1, column2....)
values (value1, value2...);

 

where table_name is the name of the table into which we want to insert data; column1, column2 etc. are column names and value1
, value2 etc. are values for the respective columns. This is quite simple, isn't it?

The following statement inserts the first record in employee_data table.

INSERT INTO employee_data
(f_name, l_name, title, age, yos, salary, perks, email)
values
("Manish", "Sharma", "CEO", 28, 4, 200000,
50000, "manish@bignet.com");

As with other MySQL statements, you can enter this command on one line or span it in multiple lines.
Some important points:

* The table name is employee_data
* The values for columns f_name, l_name, title and email are text strings and surrounded with quotes.
* Values for age, yos, salary and perks are numbers (intergers) and without quotes.
* You'll notice that we've inserted data in all columns except emp_id. This is because, we leave this job to MySQL, which
will check the column for the largest value, increment it by one and insert the new value.

Once you type the above command correctly in the mysql client, it displays a success message.

 

mysql> INSERT INTO employee_data
-> (f_name, l_name, title, age, yos, salary, perks, email)
-> values
-> ("Manish", "Sharma", "CEO", 28, 4, 200000,
-> 50000, "manish@bignet.com");
Query OK, 1 row affected (0.00 sec)

Inserting additional records requires separate INSERT statements. In order to make life easy, I've packed all INSERT statement
s into a file. Click to download the file, employee.dat.
Once you download the file, open it in a text editor. You'll notice that it's a plain ASCII file with an INSERT statement on e
ach line.

1). Migrate to the directory that contains the downloaded file.
2). Issue the following command
mysql employees <employee.dat -u username -p
3). Enter your password.

Our table contains 21 entries (20 from employee.dat file and one from the INSERT statement we issued at the beginning).

 

 

Our employee_data table now contains enough data for us to work with. Let us see how we can extract (query) it. Querying invol
ves the use of the MySQL SELECT command.

 

Data is extracted from the table using the SELECT SQL command. Here is the format of a SELECT statement:

SELECT column_names from table_name [WHERE ...conditions];

The conditions part of the statement is optional (we'll go through this later). Basically, you require to know the column name
s and the table name from which to extract the data.

For example, in order to extract the first and last names of all employees, issue the following command.

SELECT f_name, l_name from employee_data;

The statement tells MySQL to list all the rows from columns f_name and l_name.

mysql> SELECT f_name, l_name from employee_data;
+---------+------------+
| f_name | l_name |
+---------+------------+
| Manish | Sharma |
| John | Hagan |
| Ganesh | Pillai |
| Anamika | Pandit |
| Mary | Anchor |
| Fred | Kruger |
| John | MacFarland |
| Edward | Sakamuro |
| Alok | Nanda |
| Hassan | Rajabi |
| Paul | Simon |
| Arthur | Hoopla |
| Kim | Hunter |
| Roger | Lewis |
| Danny | Gibson |
| Mike | Harper |
| Monica | Sehgal |
| Hal | Simlai |
| Joseph | Irvine |
| Shahida | Ali |
| Peter | Champion |
+---------+------------+
21 rows in set (0.00 sec)

 

On close examination, you'll find that the display is in the order in which the data was inserted. Furthermore, the last line
indicates the number of rows our table has (21).

To display the entire table, we can either enter all the column names or use a simpler form of the SELECT statement.

SELECT * from employee_data;

Some of you might recognize the * in the above statement as the wildcard. Though we don't use that term for the character here
, it serves a very similar function. The * means 'ALL columns'. Thus, the above statement lists all the rows of all columns.

Another example
SELECT f_name, l_name, age from employee_data;

Selecting f_name, l_name and age columns would display something like:

mysql> SELECT f_name, l_name, age from employee_data;
+---------+------------+------+
| f_name | l_name | age |
+---------+------------+------+
| Manish | Sharma | 28 |
| John | Hagan | 32 |
| Ganesh | Pillai | 32 |
| Anamika | Pandit | 27 |
| Mary | Anchor | 26 |
| Fred | Kruger | 31 |
| John | MacFarland | 34 |
| Edward | Sakamuro | 25 |
| Alok | Nanda | 32 |
| Hassan | Rajabi | 33 |
| Paul | Simon | 43 |
| Arthur | Hoopla | 32 |
| Kim | Hunter | 32 |
| Roger | Lewis | 35 |
| Danny | Gibson | 34 |
| Mike | Harper | 36 |
| Monica | Sehgal | 30 |
| Hal | Simlai | 27 |
| Joseph | Irvine | 27 |
| Shahida | Ali | 32 |
| Peter | Champion | 36 |
+---------+------------+------+
21 rows in set (0.00 sec)

 

 

In this section of the MySQL tutorial we'll look at the format of a SELECT statement we met in the last session in detail. We
will learn how to use the select statement using the WHERE clause.

SELECT column_names from table_name [WHERE ...conditions];

Now, we know that the conditions are optional (we've seen several examples in the last session... and you would have encounter
ed them in the assignments too).

The SELECT statement without conditions lists all the data in the specified columns. The strength of RDBMS lies in letting you
retrieve data based on certain specified conditions.
In this session we'll look at the SQL Comparision Operators.

The = and != comparision operators

SELECT f_name, l_name from employee_data where f_name = 'John';

+--------+------------+
| f_name | l_name |
+--------+------------+
| John | Hagan |
| John | MacFarland |
+--------+------------+
2 rows in set (0.00 sec)

This displays the first and last names of all employees whose first names are John. Note that the word John in the condition i
s surrounded by single quotes. You can also use double quotes. The quotes are important since MySQL will throw an error if the
y are missing. Also, MySQL comparisions are case insensitive; which means "john", "John" or even "JoHn" would work!

SELECT f_name,l_name from employee_data where title="Programmer";

+--------+------------+
| f_name | l_name |
+--------+------------+
| Fred | Kruger |
| John | MacFarland |
| Edward | Sakamuro |
| Alok | Nanda |
+--------+------------+
4 rows in set (0.00 sec)

Selects the first and last names of all employees who are programmers.

SELECT f_name, l_name from employee_data where age = 32;
+---------+--------+
| f_name | l_name |
+---------+--------+
| John | Hagan |
| Ganesh | Pillai |
| Alok | Nanda |
| Arthur | Hoopla |
| Kim | Hunter |
| Shahida | Ali |
+---------+--------+
6 rows in set (0.00 sec)

This lists the first and last names of all empoyees 32 years of age. Remember that the column type of age was int, hence it's
not necessary to surround 32 with quotes. This is a subtle difference between text and integer column types.

The != means 'not equal to' and is the opposite of the equality operator.

The greater than and lesser than operators
Okay, let's retrieve the first names of all employees who are older than 32.

SELECT f_name, l_name from employee_data where age > 32;
+--------+------------+
| f_name | l_name |
+--------+------------+
| John | MacFarland |
| Hassan | Rajabi |
| Paul | Simon |
| Roger | Lewis |
| Danny | Gibson |
| Mike | Harper |
| Peter | Champion |
+--------+------------+
7 rows in set (0.00 sec)

How about employees who draw more than $120000 as salary...

SELECT f_name, l_name from employee_data where salary > 120000;
+--------+--------+
| f_name | l_name |
+--------+--------+
| Manish | Sharma |
+--------+--------+
1 row in set (0.00 sec)

Now, let's list all employees who have had less than 3 years of service in the company.

SELECT f_name, l_name from employee_data where yos < 3;
+--------+----------+
| f_name | l_name |
+--------+----------+
| Mary | Anchor |
| Edward | Sakamuro |
| Paul | Simon |
| Arthur | Hoopla |
| Kim | Hunter |
| Roger | Lewis |
| Danny | Gibson |
| Mike | Harper |
| Hal | Simlai |
| Joseph | Irvine |
+--------+----------+
10 rows in set (0.00 sec)

The <= and >= operators
Used primarily with integer data, the less than equal (<=) and greater than equal (>=)operators provide additional functionali
ty.

select f_name, l_name, age, salary
from employee_data where age >= 33;

+--------+------------+------+--------+
| f_name | l_name | age | salary |
+--------+------------+------+--------+
| John | MacFarland | 34 | 80000 |
| Hassan | Rajabi | 33 | 90000 |
| Paul | Simon | 43 | 85000 |
| Roger | Lewis | 35 | 100000 |
| Danny | Gibson | 34 | 90000 |
| Mike | Harper | 36 | 120000 |
| Peter | Champion | 36 | 120000 |
+--------+------------+------+--------+
7 rows in set (0.00 sec)

Selects the names, ages and salaries of employees who are more than or equal to 33 years of age..
select f_name, l_name from employee_data where yos <= 2;
+--------+----------+
| f_name | l_name |
+--------+----------+
| Mary | Anchor |
| Edward | Sakamuro |
| Paul | Simon |
| Arthur | Hoopla |
| Kim | Hunter |
| Roger | Lewis |
| Danny | Gibson |
| Mike | Harper |
| Hal | Simlai |
| Joseph | Irvine |
+--------+----------+
10 rows in set (0.00 sec)

Displays employee names who have less than or equal to 2 years of service in the company.

 

 

The equal to(=) comparision operator helps is selecting strings that are identical. Thus, to list the names of employees whose
first names are John, we can use the following SELECT statement.

select f_name, l_name from employee_data where f_name = "John";

+--------+------------+
| f_name | l_name |
+--------+------------+
| John | Hagan |
| John | MacFarland |
+--------+------------+
2 rows in set (0.00 sec)

What if we wanted to display employees whose first names begin with the alphabet J?
SQL allows for some pattern matching with string data. Here is how it works.

select f_name, l_name from employee_data where f_name LIKE "J%";

+--------+------------+
| f_name | l_name |
+--------+------------+
| John | Hagan |
| John | MacFarland |
| Joseph | Irvine |
+--------+------------+
3 rows in set (0.00 sec)

You'll notice that we've replaced the Equal To sign with LIKE and we've used a percentage sign (%) in the condition.
The % sign functions as a wildcard (similar to the usage of * in DOS and Linux systems). It signifies any character. Thus, "J%
" means all strings that begin with the alphabet J.
Similarly "%S" selects strings that end with S and "%H%", strings that contain the alphabet H.

Okay, let's list all the employees that have Senior in their titles.

select f_name, l_name, title from employee_data
where title like '%senior%';

+--------+--------+----------------------------+
| f_name | l_name | title |
+--------+--------+----------------------------+
| John | Hagan | Senior Programmer |
| Ganesh | Pillai | Senior Programmer |
| Kim | Hunter | Senior Web Designer |
| Mike | Harper | Senior Marketing Executive |
+--------+--------+----------------------------+
4 rows in set (0.00 sec)

Listing all employees whose last names end with A is very simple

mysql> select f_name, l_name from employee_data
where l_name like '%a';

+--------+--------+
| f_name | l_name |
+--------+--------+
| Manish | Sharma |
| Alok | Nanda |
| Arthur | Hoopla |
+--------+--------+
3 rows in set (0.00 sec)

In this section of the SQL primer we look at how to select data based on certain conditions presented through MySQL logical op
erators.

SQL conditions can also contain Boolean (logical) operators. They are
1). AND
2). OR
3). NOT

 

 

Their usage is quite simple. Here is a SELECT statement that lists the names of employees who draw more than $70000 but less t
han $90000.

SELECT f_name, l_name from employee_data
where salary > 70000 AND salary < 90000;

+--------+------------+
| f_name | l_name |
+--------+------------+
| Mary | Anchor |
| Fred | Kruger |
| John | MacFarland |
| Edward | Sakamuro |
| Paul | Simon |
| Arthur | Hoopla |
| Joseph | Irvine |
+--------+------------+
7 rows in set (0.00 sec)

Let's display the last names of employees whose last names start with the alphabet S or A.

SELECT l_name from employee_data where
l_name like 'S%' OR l_name like 'A%';
+----------+
| l_name |
+----------+
| Sharma |
| Anchor |
| Sakamuro |
| Simon |
| Sehgal |
| Simlai |
| Ali |
+----------+
7 rows in set (0.00 sec)

Okay here is a more complex example... listing the names and ages of employees whose last names begin with S or P and who are
less than 30 years of age.

SELECT f_name, l_name , age from employee_data
where (l_name like 'S%' OR l_name like 'A%') AND
age < 30;

+--------+----------+------+
| f_name | l_name | age |
+--------+----------+------+
| Manish | Sharma | 28 |
| Mary | Anchor | 26 |
| Edward | Sakamuro | 25 |
| Hal | Simlai | 27 |
+--------+----------+------+
4 rows in set (0.00 sec)

Note the usage of parenthesis in the statement above. The parenthesis are meant to separate the various logical conditions and
remove any abiguity.

The NOT operator helps in listing all non programmers. (Programmers include Senior programmers, Multimedia Programmers and Pro
grammers).

SELECT f_name, l_name, title from employee_data
where title NOT LIKE "%programmer%";

+---------+----------+----------------------------+
| f_name | l_name | title |
+---------+----------+----------------------------+
| Manish | Sharma | CEO |
| Anamika | Pandit | Web Designer |
| Mary | Anchor | Web Designer |
| Kim | Hunter | Senior Web Designer |
| Roger | Lewis | System Administrator |
| Danny | Gibson | System Administrator |
| Mike | Harper | Senior Marketing Executive |
| Monica | Sehgal | Marketing Executive |
| Hal | Simlai | Marketing Executive |
| Joseph | Irvine | Marketing Executive |
| Shahida | Ali | Customer Service Manager |
| Peter | Champion | Finance Manager |
+---------+----------+----------------------------+
12 rows in set (0.00 sec)

 

A final example before we proceed to the assignments.
Displaying all employees with more than 3 years or service and more than 30 years of age.

select f_name, l_name from employee_data
where yos > 3 AND age > 30;

+--------+------------+
| f_name | l_name |
+--------+------------+
| John | Hagan |
| Ganesh | Pillai |
| John | MacFarland |
| Peter | Champion |
+--------+------------+
4 rows in set (0.00 sec)

 

 

 

 

This section of the tutorial MySQL looks at the In and BETWEEN operators.
To list employees who are Web Designers and System Administrators, we use a SELECT statement as

SELECT f_name, l_name, title from
-> employee_data where
-> title = 'Web Designer' OR
-> title = 'System Administrator';

+---------+--------+----------------------+
| f_name | l_name | title |
+---------+--------+----------------------+
| Anamika | Pandit | Web Designer |
| Mary | Anchor | Web Designer |
| Roger | Lewis | System Administrator |
| Danny | Gibson | System Administrator |
+---------+--------+----------------------+
4 rows in set (0.01 sec)

 

SQL also provides an easier method with IN. Its usage is quite simple.

SELECT f_name, l_name, title from
-> employee_data where title
-> IN ('Web Designer', 'System Administrator');

+---------+--------+----------------------+
| f_name | l_name | title |
+---------+--------+----------------------+
| Anamika | Pandit | Web Designer |
| Mary | Anchor | Web Designer |
| Roger | Lewis | System Administrator |
| Danny | Gibson | System Administrator |
+---------+--------+----------------------+
4 rows in set (0.00 sec)

Suffixing NOT to IN will display data that is NOT found IN the condition. The following lists employees who hold titles other
than Programmer and Marketing Executive.

SELECT f_name, l_name, title from
-> employee_data where title NOT IN
-> ('Programmer', 'Marketing Executive');
+---------+----------+----------------------------+
| f_name | l_name | title |
+---------+----------+----------------------------+
| Manish | Sharma | CEO |
| John | Hagan | Senior Programmer |
| Ganesh | Pillai | Senior Programmer |
| Anamika | Pandit | Web Designer |
| Mary | Anchor | Web Designer |
| Hassan | Rajabi | Multimedia Programmer |
| Paul | Simon | Multimedia Programmer |
| Arthur | Hoopla | Multimedia Programmer |
| Kim | Hunter | Senior Web Designer |
| Roger | Lewis | System Administrator |
| Danny | Gibson | System Administrator |
| Mike | Harper | Senior Marketing Executive |
| Shahida | Ali | Customer Service Manager |
| Peter | Champion | Finance Manager |
+---------+----------+----------------------------+
14 rows in set (0.00 sec)

 

BETWEEN is employed to specify integer ranges. Thus instead of age >= 32 AND age <= 40, we can use age BETWEEN 32 and 40.

select f_name, l_name, age from
-> employee_data where age BETWEEN
-> 32 AND 40;

+---------+------------+------+
| f_name | l_name | age |
+---------+------------+------+
| John | Hagan | 32 |
| Ganesh | Pillai | 32 |
| John | MacFarland | 34 |
| Alok | Nanda | 32 |
| Hassan | Rajabi | 33 |
| Arthur | Hoopla | 32 |
| Kim | Hunter | 32 |
| Roger | Lewis | 35 |
| Danny | Gibson | 34 |
| Mike | Harper | 36 |
| Shahida | Ali | 32 |
| Peter | Champion | 36 |
+---------+------------+------+
12 rows in set (0.00 sec)

You can use NOT with BETWEEN as in the following statement that lists employees who draw salaries less than $90000 and more th
an $150000.

select f_name, l_name, salary
-> from employee_data where salary
-> NOT BETWEEN
-> 90000 AND 150000;

+---------+------------+--------+
| f_name | l_name | salary |
+---------+------------+--------+
| Manish | Sharma | 200000 |
| Mary | Anchor | 85000 |
| Fred | Kruger | 75000 |
| John | MacFarland | 80000 |
| Edward | Sakamuro | 75000 |
| Alok | Nanda | 70000 |
| Paul | Simon | 85000 |
| Arthur | Hoopla | 75000 |
| Hal | Simlai | 70000 |
| Joseph | Irvine | 72000 |
| Shahida | Ali | 70000 |
+---------+------------+--------+
11 rows in set (0.00 sec)

 

 

for more lessons :-
http://www.webdevelopersnotes.com/tutorials/sql/online_mysql_tutorial_ordering_data.php3
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
install phpmyadmin

go to server root directory
wget http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.9.2-english.tar.gz?download
tar -xzvf phpMyAdmin-2.9.2-english.tar.gz
cd phpMyAdmin-2.9.2-english
cp -p config.sample.inc.php config.inc.php

then call it through browser as ip/phpmyadmin.....

this will show one error
please give any name say test in between '' of the line in the file config.inc.php

the line is $cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

give a username and password

if this shows an error. The solution is given below.
-------------------------------------------------
Run mysql and login as root:

mysql -u root -p

Then, paste the following command, editing as necessary, to change the password of the user to the old format.

UPDATE mysql.user
SET password=OLD_PASSWORD('somepassword')
WHERE user='someuser'
AND host='somehost';

After you have set the passwords to the old format, flush the tables.

flush privileges;

Then exit the mysql client with "quit" and you are set.
-------------------------------------------------
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&