Library tutorials & articles
SQL In Simple English
- Introduction
- Lets get started
- Basic SELECT statements
- Inserting, Deleting & Updating
- More Advanced SQL
- Show me more!
Inserting, Deleting & Updating
What is the INSERT statement? How do I use it?
The INSERT statement lets you insert information
into a database. A few examples are shown belowINSERT INTO people VALUES ('Bush', 'George', 47 , 'White
House', 'Washington')Would insert a new row at the bottom of the table people consisting
of the values in parentheses in the above statement.INSERT INTO people (lastname, city) VALUES ('Gates', 'Redmond')Would insert a new row at the bottom of the table people consisting of
only 2 values as present in the above statement, namely 'Gates' and 'Redmond'.
The remaining columns for that particular record would be left empty (null).
Note : A null value is different from 0 or ''(Empty String). A perfect
example of this would be a column describing the hair colour for many people.
In case the person is bald then the value of the colour should be null rather
than empty. This would be perfect from the database design view. A particular
entity which doesn't exist should be represented similarly and not by empty Strings.
How do I delete a record from a database?
Use the DELETE statement to remove records or any
particular column values from a database.DELETE FROM people WHERE lastname = 'Hunter'Would remove the entire record which represents any person whose lastname
is 'Hunter'. In our case it would remove 1 record from the sample database table
people. It would remove all the values that were a part of that record.
Is there a way to update any record in a database?
Yes. You could use the UPDATE statement. The update
statement updates (or replaces) those values that were specified in the SQL statement
with the new values provided.UPDATE people SET age = 50, city = 'Mumbai' WHERE (lastname
= 'Hunter' AND firstname='Jason')Would change Jason Hunter's age from 41 to 50 and would make him shift
his residence from 'San Jose' to 'Mumbai'. Isn't that cool?? A new Java Guru
is Mumbai !!
Related articles
Related discussion
-
How to receive data in web server sending from GPRS modem
by AshokSingh (1 replies)
-
how to make smtp in vb.net
by konikula (1 replies)
-
copying access DB to SQL DB
by konikula (1 replies)
-
MS Access in 3 different language
by konikula (2 replies)
-
How do I update a table that has an ID from a table that does not have an ID but has a PIDM?
by konikula (1 replies)
Related podcasts
-
Stack Overflow: Podcast #31
This is the thirty-first episode of the StackOverflow podcast, where Joel and Jeff discuss.. stuff! Based on some comments from Podcast #30, we now know that “Learning about NP-Completeness from Jeff is like learning about irony from Alanis Morissette”. It’s funny b...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Oracle Apps Database Administrator - Standplaats: Utrecht
in AMSTERDAM (€50K-€90K per annum) -
Business Analist BI/Datawarehousing
in Amsterdam (€50K-€90K per annum) -
Oracle Ontwikkelaar
in Amsterdam (€50K-€90K per annum)
Events coming up
-
Jun
16
Code Generation 2009
Cambridge, United Kingdom
A developer event with a practical focus on helping people get to grips with code generation tools and technologies.
Hi I would first like to say your site has been really helpful to me.
When using ASP to display database information in a web page you might use
[courier new]
Set adoConnect = Server.CreateObject("ADODB.Connection")
adoConnect.Open "Reports"
Set onIndex = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM index WHERE number=10"
onIndex.Open strSQL, adoConnect
[/courier new]
Then if you wanted to display the recordset you could use
[courier new]
<% onIndex=("Number") %>
[/courier new]
but what I can't work out is if your select statement uses COUNT how do you display the result
[courier new]
Set adoConnect = Server.CreateObject("ADODB.Connection")
adoConnect.Open "Reports"
Set onIndex = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT COUNT(*) FROM index WHERE number=10"
onIndex.Open strSQL, adoConnect
[/courier new]
sorry probably it has been too long and may be you've got the answer but try this
select * from table where date> #2/2/1979#
hi..
check this ... should work
select * from tablename where DateOfBirth<TODATE('10/9/1976','mm/dd/yyyy')
try using TO_DATE with the date you want.. i have used this before in this manner..
hope it helps
bye
Thanks, very helpful.
What about dates though? What is the code for finding dates using the SELECT statement eg 'SELECT from * WHERE DateOfBirth < 10/9/76 10:01:10', I can't get it to work.
This thread is for discussions of SQL In Simple English.