MYSQL COMMANDS AND USE

MYSQL COMMANDS AND USE
PHP 4 version of the mysql commands and short descriptions

PHP 4 version of MySQL, and short descriptions of all commands that can be used for communication.
mysql_affected_rows
The number of rows affected by a previous transaction.

mysql_close
Closes the specified mysql connection.

mysql_connect
Opens a database connection to the server.

mysql_create_db
Opens in MySQL database.

mysql_data_seek
The result is the order line.

mysql_db_query
Sends the query to MySQL.

mysql_drop_db
Deletes the database server.

mysql_errno
MySQL gives the error number in the previous process.

mysql_error
MySQL gives the error message, the previous process.

mysql_fetch_array
The results of the array variable is.

mysql_fetch_field
As a result, the table is the name of the object.

mysql_fetch_lenghts
The result is the length of the array variable table.

mysql_fetch_object
Gets a result row as an object.

mysql_fetch_row
Variable table, you get a result.

mysql_field_name
The result of the name of the table gives the result table.

mysql_field_seek
Index that takes place as a result table.

mysql_field_table
The domain name of the table gives the result.

mysql_field_type
The resulting field indicates what type.

mysql_field_flags
The resulting space is defined which specifies the type of extra parameters.

mysql_field_len
Field gives the length of the resulting database.

mysql_free_result
Frees the memory assigned to the results.

mysql_insert_id
Returns the value of the automated data placement to the previous data.

mysql_list_fields
The resulting lists of all the table fields.

mysql_list_dbs
Lists all the databases on the server.

mysql_list_tables
Lists all the tables in the database.

mysql_num_fields
The resulting field gives the number.

mysql_num_rows
Returns the number of rows in result.

mysql_pconnect
Defines a permanent connection to the server.

mysql_query
Sends the query to the database.

mysql_result
The results of the query are returned.

mysql_select_db
Select from the server database.

mysql_tablename
To belong to the given name of the table gives the area.

SQL COMMANDS
Database Created

Database_ismi CREATE DATABASE;

EX: CREATE DATABASE, Mersin;

Created in the database table

CREATE TABLE database_ismi;

EX: CREATE DATABASE students;

Adding Data to SQL in the command

INSERT INTO table_name VALUES (‘Data1’, ‘veri2’, ‘veri3’,…..);

Crafts table command to add a new profession

EX: INSERT INTO jobs VALUES (’11 ‘,’ Teacher ‘, ’12’, ’20 ‘);

eg: INSERT INTO Students VALUES (23, ‘Length’, ‘GULER’);

Getting Data from the table command (list command)

SELECT kolon1, kolon2, kolon3 colony …. FROM table_name;
SELECT * FROM table_name (to take all);

eg: SELECT id, kayitno FROM Students;

eg: SELECT id, meslekno, meslekismi, girissaati, cikissaati FROM professions;

eg: SELECT name, surname, address FROM staff;

Ranking of the captured data from a table

ORDER BY domain, ASC; (ASC)
Domain, an ORDER BY DESC; (DESC)

EX: SELECT id, meslekno, meslekismi, girissaati, cikissaati FROM jobs ORDER BY ASC meslekismi;
EX: SELECT id, meslekno, meslekismi, girissaati, cikissaati FROM jobs ORDER BY DESC meslekismi;

Dates of birth of the same name, last name, sorted according to the shape of a data
eg: SELECT id, name, last name, dtarihi DTARİH FROM staff ORDER BY DESC, name, surname, ASC;

Any SQL command that operate according to a Contingent (Required Instruction)

WHERE condition şart_alanı şart_ifadesi (=,<,>)

eg: SELECT id, name, last name, dtarihi FROM staff WHERE name = ‘bob’;
eg: SELECT id, name, last name, dtarihi FROM staff WHERE dtarihi <’01 .01.1967 ‘ORDER BY DESC BASE;

TABLE

id name salary meslekid meslekadi address Sayad dtarihi Dyer

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer Dyer FROM WHERE costs plus = ‘London’;

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer FROM WHERE salary costs plus> 300 ORDER BY salary DESC;

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer Dyer FROM WHERE costs plus = ‘London’ AND meslekadi = ‘doctor’ ORDER BY NAME ASC;

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer FROM WHERE salary costs plus <250 OR meslekadi = ‘servant’ ORDER BY NAME ASC;

Between the two Vari Processing Command

bakilacak_alan BETWEEN value1 AND value2

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer FROM WHERE salary costs plus BETWEEN 200 AND 300 ORDER BY NAME, LASTNAME DESC;

eg: SELECT id, name, Sayad, dtarihi, salaries, meslekid, meslekadi the address s, Dyer FROM WHERE costs plus dtarihi BETWEEN ’06 .05.1989 ‘AND ’01 .01.2000’;

IN COMMAND

bakilacak_alan IN (value1, value2, …., the value of value)

teknikservis IT purchase accounting

eg: SELECT * FROM WHERE meslekadi costs plus IN (‘IT’, ‘accounting’, ‘purchase’, ‘teknkservi s’)

eg: SELECT * FROM WHERE costs plus meslekadi = ‘IT’ OR meslekadi = ‘accounting’ OR meslekadi = ‘purchase’ OR meslekadi = ‘teknkservis’;

Search within the command

LIKE bakilacak_alan bakilacak_deger note (not important where the bay%)

eg: SELECT * FROM WHERE ıcretler address LIKE ‘% host%’

eg: SELECT * FROM WHERE ıcretler address LIKE ‘% Turkey’

Relational Tables

personnel

id, name, surname, address, birthplace, sicilno, isebaslama, with sex, medenidurumu, dtarih

costs plus
id, per_sicil_no, aylikucret, sigortaprimi, yemekyardi, yakityardimi

==========================================

eg: SELECT name, surname, aylikucret FROM staff, fees WHERE sicilno = per_sicil_no;

eg: SELECT name, last name, salary FROM staff, fees sicilno = per_sicil_no AND WHERE Birthplace = ‘London’ AND address LIKE ‘% istanbul’;
ie: more than 300 salary and insurance of the underlying

SELECT name, surname, sigortapirimi FROM staff, fees AND WHERE per_sicil_no aylikucret sicilno => 300 AND sigortaprimi> 0;
eg: for 15 years, the employee’s salary under 200 YTL firstname.lastname yenimahallede based staff, and address lists pprogram

SELECT name, surname, address FROM staff, fees sicilno = per_sicil_no AND WHERE aylikucret <200 AND address LIKE ‘% host%’ AND isebaslama BETWEEN (’07 .05.1991 ‘AND ’06 .05.1992’);

EX: NAME AND E accounting and computing unmarried women 30 years of age working in any of buying a small salary that more than 100 YTL

SELECT * FROM staff, fees
WHERE sicilno = per_sicil_no
AND meslekadi = ‘accounting’ OR meslekadi = ‘IT’ OR meslekadi = ‘purchase’
AND name LIKE ‘E%’ AND sex = ‘Sex’
AND medenidurumu = ‘single’
AND dtarih> ’01 .011977 ‘
AND aylikucret> 100;

Data Delete command from the table

DELETE FROM table_name WHERE condition

DELETE FROM wages, staff WHERE AND aylikucret per_sicil_no sicilno = <100;

eg registration number 123 that deletes the record from the database program

DELETE FROM wages, staff WHERE per_sicil_no = ‘123 ‘AND sicilno = ‘123’;

Data update command

UPDATE table_name SET value1 = domain1, domain2 = value2 … FieldName = value;

A neighborhood W of the street address of 123 registration number of the personnel of Ankara Yenimahalle

UPDATE staff SET address = ‘A street Yenimahalle Ankara neighborhood W’ WHERE sicilno = ‘123 ‘;

Costs plus aylikucret * UPDATE SET aylikucret = 1.2;

UPDATE wages, staff SET ylikucret = aylikucret-100 WHERE meslekadi = ‘IT’ AND sicilno = per_sicil_no;

Grouping Commands

The largest command:

SELECT MAX (field_name) FROM table_name

the maximum salary of the staff:
SELECT MAX (aylikucret) FROM costs plus

ie, the more fuel-assistance program, showing the salary of the staff and the registration number

SELECT aylikucret, per_sicil_no, MAX (yakityardimi) FROM costs plus

Least-Command:

SELECT MIN (field_name) FROM table_name

TOTAL ACQUISITION COMMAND:

SELECT SUM (field_name) FROM table_name

the total fuel subsidy:
SELECT SUM (yakityardimi) FROM Fees;

Average command:

SELECT AVG (field_name) FROM table_name

SELECT AVG (aylikucret) FROM wages, staff WHERE meslekadi = ‘IT’;
SELECT AVG (yakiyyardimi) FROM wages, staff WHERE meslekadi = ‘accounting’ AND gender = ‘Female’;

RECORD NUMBER OF COMMAND

SELECT COUNT (*) FROM table_name

SELECT COUNT (*) FROM staff;

SINGLE RECORD NUMBER OF COMMAND

SELECT COUNT (Distict field_name) FROM table_name

There are many different family group working with us

SELECT COUNT (Distict Sayad) FROM staff

Our company has several different departments.

SELECT COUNT (Distict meslekadi) FROM staff

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir