Friday, August 20, 2021

Lets learn mysql from beginner: codewithme

 day1:

lets learn mysql queries to create table and database;

lets take one table sample from that we will write queries later we will learn to create the table and data base

photo from w3school 
once we create the above table and to display all the details as above we need to write the query as:
SELECT SYNATX: SELECT column1,column2.... FROM  tablename
here for us we use * to select all columns and table name is Customer.
SELECT * FROM Customer;

it will display all the details 

To display a particular row we can retrieve using customerID as it is a primary key.

Example:

SELECT * FROM Customer where CustomerID=2;

2 Ana Trujillo Emparedados y helados  Ana Trujillo  Avda. de la Constitución 2222  México D.F. 05021 Mexico

TO select ANY COLUMN from customers then we can use any column name.
example: SELECT City FROM Customers;
it will display all the cities.

To display different values of a particular column we can use keyword "DISTINCT"
example: SELECT DISTINCT Country FROM Customers;
only countries that are different wil be displayed. if any country is repeated many times it will be displayed only once.

WHERE clause: it used to filter the records more  to get more specific data
Syntax: SELECT col1,col2,col3 FROM table_name WHERE= condition;

 


No comments:

Post a Comment

Featured post

Major Challenges for economic development of Nepal | Loksewa old Question Paper 2078

Q. Wha t do you mean by Economic Growth and Economic Development?  What are the main challenges of economic development of Nepal? Give your ...

Popular Posts