The document contains examples of SQL queries that can be used to create a database table, select data from a table, update records in a table, delete records from a table, and truncate or empty a table. The CREATE statement defines a table with various data types for different fields. The SELECT statements show how to retrieve specific fields or records matching certain criteria. The UPDATE statement demonstrates how to modify field values. The DELETE statement removes records. And the TRUNCATE statement empties the entire table.
The document contains examples of SQL queries that can be used to create a database table, select data from a table, update records in a table, delete records from a table, and truncate or empty a table. The CREATE statement defines a table with various data types for different fields. The SELECT statements show how to retrieve specific fields or records matching certain criteria. The UPDATE statement demonstrates how to modify field values. The DELETE statement removes records. And the TRUNCATE statement empties the entire table.
The document contains examples of SQL queries that can be used to create a database table, select data from a table, update records in a table, delete records from a table, and truncate or empty a table. The CREATE statement defines a table with various data types for different fields. The SELECT statements show how to retrieve specific fields or records matching certain criteria. The UPDATE statement demonstrates how to modify field values. The DELETE statement removes records. And the TRUNCATE statement empties the entire table.
id int(11) NOT NULL PRIMARY KEY auto_increment, name varchar(50), age int(2), info text, date date); Exemple select SELECT * FROM name_table WHERE id = '16'; SELECT id, field1, field2 FROM name_table WHERE id = '16';//afiseaza cimpurile id,field1,field2 inregistrarilor cu id 16 SELECT *From name_table;//tot continutul SELECT user_name , email FROM name_table; // doar user_name/email la toate inregistr SELECT email FROM name_table WHERE username='misha';//emailul inregistrarii cu username-ul dat SELECT * FROM name_table WHERE user_id <=2;//afiseaza toate inregistrarile cu id <=2 SELECT * FROM name_table WHERE user_id=1 or user_name = 'nettuts';//care au idul 1 sau urername-ul nettus SELECT * FROM name_table WHERE create_date IN (2009-12-15','2009-12- 16');//inregistrarile cu cimpul create_date dat SELECT * FROM name_table WHERE ->email LIKE '%tuts%';//Toate inregistraarile care au in email secventa tuts SELECT * FROM name_table ->ORDER BY create_date;//ordonare dupa cimpul create_date SELECT * FROM name_table ->ORDER BY name DESC//ordonare in ordine alfabetica DESC-descendent ASC-ascendent sandartASC SELECT * MIN(virsta) se selecteaza virsta minima Exemple update UPDATE name_table SET create_date = '2009-12-01' ->WHERE create_date = '2009-12-14' LIMIT 1;//rescrie cimpul create_date in care era '2009-12-14' daca sunt mai multe cu aceastadata se schimba numai unul UPDATE name_table SET virsta = virsta +1; // adauga la toate inregistrarile +1 la virsta Exemple DELETE DELETE FROM name_table WHERE user_name= 'batman';//stergerea inregistrarii cu user)name 'batman' Exemple TRUNCATE TRUNCATE TABLE name_table;//sterge si recreaza tabelul