SQL Commands: Difference between revisions

From Fact Weaver
No edit summary
No edit summary
Line 2: Line 2:


Selecting a single Column from a table:
Selecting a single Column from a table:
<code>  
<nowiki>
This will select the column "Name" from the "People" Table.
SELECT name  
SELECT name  
FROM people;  
FROM people;  
</code>
</nowiki>
This will select the column "Name" from the "People" Table.
 


Selecting multiple columns from a table:
Selecting multiple columns from a table:
<code>  
<nowiki>
This will select the Name and Birthrate column from the people table.
SELECT name, birthdate
SELECT name, birthdate
FROM people;  
FROM people;  
</code>
</nowiki>
This will select the Name and Birthrate column from the people table.
 


<code>  
<nowiki>
This will select all columns from a table.
SELECT *
SELECT *
FROM people;  
FROM people;  
</code>
</nowiki>
This will select all columns from a table.
 


<code>  
<nowiki>
This will select 10 rows with all columns from a table.
SELECT *
SELECT *
FROM people
FROM people
LIMIT 10;  
LIMIT 10;  
</code>
</nowiki>
 
 
<nowiki>
This will select 10 rows with all columns from a table.
This will select 10 rows with all columns from a table.
SELECT *
FROM people
LIMIT 10;
</nowiki>

Revision as of 02:14, 12 September 2023

Below I have listed the most common commands that I am using when acquiring data from a database

Selecting a single Column from a table:

This will select the column "Name" from the "People" Table.
SELECT name 
FROM people; 


Selecting multiple columns from a table:

This will select the Name and Birthrate column from the people table.
SELECT name, birthdate
FROM people; 


This will select all columns from a table.
SELECT *
FROM people; 


This will select 10 rows with all columns from a table. 
SELECT *
FROM people
LIMIT 10; 


This will select 10 rows with all columns from a table.
SELECT *
FROM people
LIMIT 10;