Introduction SQL Structured Query Language PDF
Introduction SQL Structured Query Language PDF
Written By TheVBProgramer.
Navigate To
Home This tutorial is not directly related to Visual Basic 6. But you will use this information
Tutorials heavily when writing any VB6 program that accesses a database. This teaches you all
the basics and then some of the SQL language - it does so using Access databases. The
Source Code Samples
SQL tutorial is pretty lengthy, but if you press through it you will really understand how
VB.NET Tutorials
database programming works.
Add Your Tutorial
Forums Prerequisites
Articles This tutorial presumes that the reader has a working knowledge of
External Links basic database table design principles, including basic
Advertise Here! normalization and relationships (one-to-many, one-to-one, many-to-
Contact Us
many). Once a database has been designed and its tables have
been populated with data, SQL can be used to manipulate the data
in those tables.
Guides
Beginner Guide Tutorials on database normalization and relationships can be found
Controls Guide on various Internet sites. Even without this background, you may be
Database Guide able to glean some of this knowledge by going through the
Introduction to SQL
exercises in this tutorial.
Using Data Control
You will need to have MS-Access 2000 (or higher) installed on your
Using DAO Code
system to perform the examples presented in this tutorial. For one of
Using RDO
the examples, you will also need MS-Excel.
Using ADO
ADO and ListView About this Tutorial
ADO stored procs
Using Crystal Reports The sample database used for this tutorial is a modified version of
the sample "Northwind Traders" database, provided by Microsoft in
Visual Studio and MS-Office.
User login
Username: * The original database provided by Microsoft ("NWIND.MDB")
contains many features that would detract from the purpose of this
tutorial (in that the purpose of this tutorial is teach you how to write
Password: *
SQL to interact with database tables). The original database "shows
off" many features of an MS-Access database: it contains many
Log in forms and reports; it also manipulates how some of the data
appears when you open a table to view its contents (for example, a
Create new account
column may actually contain a numeric code, but the table
Request new password
datasheet view is set up to show the description corresponding to
that code; also, in many cases a "display name" was set up for the
column for example, a column might actually be called
"CustName" but it would appear as "Customer Name" when you
opened the table).
A Note on Terminology
In this tutorial, the term record will be used interchangeably with the
term row; and the term field will be used interchangeably with the
term column.
Introduction to SQL
In the mid 1970s, SQL was developed under the name SEQUEL
(for Structured English Query Language?) at the IBM San Jose
research facilities to be the data manipulation language for IBM's
prototype relational model DBMS called "System R". In 1980, the
language was renamed SQL to avoid confusion with an unrelated
hardware product called SEQUEL.
SQL is currently used (and has been for quite some time) as the
data manipulation language for most relational database
management products on the market today. This includes IBM's
DB2, Oracle, XBase (dBase, FoxPro, etc.), MS SQL Server, and
Access. Although there are various SQL "standards" (SQL-89, SQL-
92, etc.), there are variations in the "dialects" of SQL "spoken" by
the different vendors. For example, there are some things you can
do in Oracle SQL that you can't do with Access, and vice-versa.
DML Statements
DDL Statements
Open the database that you want to work with (in this case,
NWINDVBP.MDB).
The Show Table dialog box appears (note: your list of table
names will not initially contain all of the table names shown
here). Click Close:
To run the query, click the Run button on the toolbar (it's the
"exclamation point" icon):
Once you have returned to SQL view, you can overwrite the SQL
command that you entered with the next SQL query you wish to
enter. Before you overwrite the existing query, you can save it, as
explained below.
Saving Queries
To save a query in the Access database, click the Save button (the
diskette icon) on the Access toolbar. This will enable you to recall
the query from the Queries tab in Access.
If you wish to only save the SQL statement (but not save the query
in Access), you can select the text you entered in SQL view, copy it,
then paste it into another application (such as Notepad, Word, or the
VB code editor). Conversely, you can type up a SQL query in
Notepad or Word, copy it, then paste it into the SQL View text-entry
screen.
When you are at the point where you are writing a VB application
that requires embedded SQL statements, you can use the graphical
query capabilities of Access to "cheat". For example, if you can't
recall exactly how to phrase a particular SQL statement, you can
build a test query in Access with the graphical designer and run it. If
it produces the desired results, you can switch over to SQL View
and "steal" the code (i.e., copy it from Access and paste into VB).
However there is no substitute for simply "knowing" how to get
the job done and you may need to work with a DBMS that does
not have a graphical designer for queries.
For each example in the following tutorial, please key in and run the
SQL commands as shown. The SQL commands to key in will be
shown in bold Courier, like the following:
The expected results of each query will also be shown, so that you
can compare them to your results.
Example 1:
Retrieve all columns and all rows from the Employees table.
Example 2:
Retrieve the Product ID, product name, and unit price from all rows
of the Products table:
SELECT ProductName
FROM Products
WHERE ProductID = 19
Example 4:
Which customers are from Mexico? (Show Customer ID, company
name, contact name, and contact title in the results.)
Example 5:
Which employees were hired on October 17, 1993? (Show
employee first and last name, and title in the results.)
Example 6:
Which meat/poultry products (CategoryID = 6) have less than 10
units in stock? (Show product ID, product name, category ID, and
units in stock in the results.)
Example 7:
Which items in the Product table are classified as meat/poultry or
have less than 10 units in stock? (Show product ID, product name,
category ID, and units in stock in the results.)
You can join multiple conditions using AND and OR. When both
AND and OR are used in the WHERE clause, "AND" takes
precedence. This precedence can be overridden by using
parentheses. Examples 8 and 9 illustrate this:
Example 8:
Show the product name, units in stock, category ID, and unit price
for seafood products (category ID = 8) that have at least 100 units in
stock, or for any item whose unit price is greater than $50.
Example 9:
Show the part product name, units in stock, category ID, and unit
price for products that have at least 100 units in stock, and that are
either classified as seafood (category ID = 8) or have a unit price
greater than $50.
Using NOT
Example 10:
Show the company name, contact name, and country for all non-US
suppliers.
Some DBMS' use "!=" for "not equal to" in addition to or instead of
"<>".
Example 11:
Show the Product ID, product name, and unit price for all products
that have a unit price between $10 and $15
(inclusive):
Example 12:
Show the Order ID, Customer ID, and order date for orders that
occurred between February 1 and February 7, 1995.
Example 13:
Show the OrderID, ProductID, UnitPrice, Quantity, Discount, and
line item total for order line items that total at least
$300.
Note also that the table "Order Details" has an embedded space in
its name. Although this is not good practice, Access
will allow it for all of its objects (tables, columns,
queries, etc.). When an object name contains
embedded spaces (and other odd characters), you
must enclose it square brackets as was done in the
example above.
Example 14:
Repeat Example 13, except call the computed column
"LineItemTot".
Using LIKE
Example 15:
Show company name, contact name, and title for customers whose
contact person is considered a "manager".
Using IN
Example 16:
Show company name and address information for all suppliers
located in France, Germany, and Italy.
You can sort the results of your query on any field or fields by using
an ORDER BY clause.
Example 17-a:
Show the category ID, unit price, and product name for all products,
sorted by unit price (low to high).
Example 17-b:
Show the category ID, unit price, and product name for all products,
sorted by unit price (high to low).
Example 18:
Show the category ID, unit price, and product name for all products,
sorted by unit price (high to low) WITHIN category ID.
The syntax for the COUNT function requires that the word COUNT
be followed by a field name in parentheses; normally, you would
place an asterisk between the parentheses to signify "any field":
COUNT(*). The COUNT function counts records; it is not dependent
on any particular field within a record.
Example 19:
How many products are classified as beverages (category ID 1)?
Example 20:
How many order lines do we have, and what is their total value?
Note: If you wanted to format the total, you could wrap the Format$
function around the SUM expression as follows:
Example 21:
Display the total order line value, average order line value, highest
order line value, and lowest order line value.
Using DISTINCT
Example 22-a:
As a verification, run the query below to see that any particular
customer may have more than one order in the Orders table:
Example 22-b:
Use the DISTINCT keyword to show each customer in the
ORDERS table only once.
STOP. Do not get rid of the above query; we're going to save it shortly.
Now a problem is going to present itself. Suppose you are asked "how many
customers have orders?" In Oracle and other DBMS' (but not Access), DISTINCT
can be used as a function, which would enable you to satisfy this question using
one query, like so:
Oracle would return the correct results, but attempting the above in Access would
result in an error. What to do?
Example 22-c:
The following query will save its results to a table named
tblCustsWithOrders:
Example 22-d:
Get a count of the number of unique customers in the ORDERS
table by using the COUNT function on the saved qryDistinctCust
query (note that Access allows you to use a saved query (QueryDef)
in place of a table name in a SELECT query).
Example 22-e:
Get a count of the number of unique customers in the ORDERS
table by using the COUNT function on the new
tblCustsWithOrders table.
Subqueries
Example 23:
Show all fields of Order table for orders that were placed on the
most recent order date.
SELECT *
FROM Orders
WHERE OrderDate = (SELECT
MAX(OrderDate) FROM Orders)
Note: The dates in this table do not have a time component to them.
If they did, the query would have to do a little more
work to specify the desired date.
Example 24:
Show the OrderID, ProductID, UnitPrice, Quantity, Discount, and
line item total for order lines that exceed the average
order line total.
Example 25:
Show the orders will be shipped by either Speedy Express or
Federal Shipping.
SELECT *
FROM Orders
WHERE ShipVia
IN (SELECT ShipperID FROM Shippers
WHERE CompanyName IN ('Speedy
Express', 'Federal Shipping'))
SELECT *
FROM Orders
WHERE ShipVia IN (1, 3)
When you group data, you create a query that produces one record
for each unique value of a field (or combination of fields) in a table
(limited by the WHERE clause, if there is one). Any of the SQL
functions discussed earlier (COUNT, SUM, AVG, etc.) apply to the
grouped record.
Example 26:
Show the order ID and order total for each order.
Just as the WHERE clause can be used to limit the rows that are
included in the result of a SQL command, the HAVING clause can
be used to limit the groups that are included.
Example 27:
Show the order number and order total for each order, but include
only orders that have a total greater than $1000.
FYI: Even when you use an alias for a computed column, you must
still use the expression, not the alias, in the HAVING
clause (this also applies to the WHERE and ORDER
BY clauses if a computed column is used with
either of these, it is the expression, not the alias, that
must be specified.)
Example 28:
For each order, show the number of order lines that make up that
order.
Example 29:
For each order, show the number of order lines that make up that
order; but only include orders containing three or more
items.
Example 30:
For each order, show the number of order lines that make up that
order, but only for orders that include product IDs 4 or 5 (a "Chef
Anton" product).
In this example, the SQL interpreter must perform two "passes" behind the scenes. First it
applies the WHERE clause to the table. From that resulting set of records, the grouping is
performed.
Example 31:
For each order, show the number of order lines that make up that
order, but only for orders that include product IDs 4 or 5 (a "Chef
Anton" product) and that have at least three or more total items.
GROUP BY OrderID
As in the previous example, the SQL interpreter must perform a number of passes
behind the scenes. First it applies the WHERE clause to the table. From that resulting set
of records, the grouping is performed. From the grouped set of records, the HAVING
clause is then applied.
One of the results of normalizing your tables is that most queries will
draw on several tables in order to get the desired result. As a result,
most of the queries you create will need to combine two or more
tables. In Access SQL, tables are joined by specifying which fields
of the tables you want to match on, either in a WHERE clause or in
a JOIN clause.
Example 32-a:
List the order ID and product name for each order line on the Order
Details table.
When you join two or more tables and those tables share
common field names, those field names must be qualified in the
query this is the case in the query above for the ProductID
field (both the Order Details and Products tables have a field
with that names). To qualify a field name, use the syntax
tablename.fieldname.
To understand why the query works the way it does, let's explore a
little relational database theory:
Example 32-b:
Modify the query in 32-a to use table name aliases:
Note: Some database systems do not require (and some will not
allow) the word AS to specify an alias (in those
systems, the table name is separated from the alias
name with just a blank space).
As an alternative to specifying the join criteria in the WHERE clause, Access SQL
allows you to specify the join criteria with the INNER JOIN clause, which is part of
the FROM clause. The basic syntax is:
SELECT fields
FROM table1 INNER JOIN table2 ON table1.field = table2.field
The INNER JOIN syntax is not supported on all database systems, but it is on
most (including SQL Server and more recent versions of Oracle).
Example 32-c:
List the order ID and product name for each order line on the Order
Details table. Use the INNER JOIN clause to specify the join
criteria.
On the one hand, specifying join criteria with the WHERE clause is
universally acceptable on all database systems that use SQL. On
the other hand, INNER JOIN is preferred in Access SQL, because
this format makes the join criteria explicit, rather than inferring it from
the WHERE clause the WHERE clause is then reserved for
selection criteria, rather than doing dual-duty as a join specifier.
Future examples in this tutorial will show joins using both formats.
Example 33:
List the order ID, customer ID, and order date together with the sales
rep first name and last name for the sales rep who made the order
for all orders made in the month of September, 1994.
-- or -
Example 34:
Find the description for every product included in order number
10250.
SELECT ProductName
FROM [Order Details] AS OD, Products
AS P
WHERE OD.ProductID = P.ProductID
AND OD.OrderID = 10250
-- or --
SELECT ProductName
FROM [Order Details] AS OD INNER JOIN
Products AS P ON OD.ProductID =
P.ProductID
WHERE OD.OrderID = 10250
-- or --
SELECT ProductName
FROM Products
WHERE ProductID IN (SELECT ProductID
FROM [Order Details] WHERE OrderID =
10250)
The next example joins three tables together and shows three
different ways to get the results (joining with WHERE, INNER JOIN,
or nested subquery):
Example 35:
Find the order ID and order date for every order that includes a
product with "Chef Anton" in the product name.
-- or --
-- or --
Note: The DISTINCT keyword was used because if a particular order contained
more than one "Chef Anton" product, that OrderID would be
duplicated in the resultset. We only want to see the unique
OrderIDs (and their dates) for all orders that have one or more
Chef Anton products.
Comprehensive Example
Example 36:
This query incorporates most of the major SQL clauses discussed
so far. This query joins four tables together to show the Order ID,
order date, customer (company name), employee name and order
total for all orders made in the month of January 1995 that totalled
$1500 or more.
-- or --
Outer Joins
Example 37:
List the employee first name and employee last name for all
employees, together with the order IDs and order dates for orders
made by that employee (if any) for the week of September 26
through September 30, 1994. (If an employee made more than one
order during that time period, that employee will show up more than
once.)
Note: In order for this query to produce the desired results, a table
expression (sometimes called an in-line view or in-line table) is
used as the second table being joined in the SQL statement. In
many cases, most DBMS' will allow a table expression to be used
where a table name is expected. The table expression SELECT *
FROM Orders WHERE OrderDate BETWEEN #9/26/1994# AND
#9/30/1994# specifies a subset of records from the Orders table for
the desired date range.
In the results above, for employees that don't have orders, the
OrderID and OrderDate columns will contain NULL. This fact
can be used in the type of query that asks the question,
"which employees do NOT have orders?":
Example 38:
List the employee first name and employee last name for all
employees for that had no orders for the week of September 26
through September 30, 1994.
Self-Joins
Example 39-a:
List the employee ID, last name, and first name for each employee,
together with the last name and first name of that employee's
supervisor.
SELECT E1.EmployeeID, E1.LastName,
E1.FirstName,
E2.LastName, E2.FirstName
FROM Employees AS E1 INNER JOIN
Employees AS E2
ON E1.ReportsTo = E2.EmployeeID
Example 39-b:
Revise the query written in exercise 41-a to use a LEFT JOIN, so
that all employee records will be selected, whether or not they have
a supervisor:
UNION Queries
Example 40:
List the employee first name and employee last name for employees
that either placed orders on the week of September 26 through
September 30, 1994, or employees that ever had an order
containing a Chef Anton product (product IDs 4 or 5), or both.
Include in the listing a column indicating which of these conditions
was met.
All queries in a UNION must request the same number of fields, but they
don't have to be the same size or data type (this restriction does exist in other
database systems).
Use aliases only in the first SELECT statement, because they are ignored in
all others
You can use an ORDER BY clause at the end of the last query argument to
display the returned data in a specified order. In the ORDER BY clause, refer
to fields by what they are called in the first SELECT statement.
Part III: Updating Data and DDL Queries
Example 41:
Change the contact name for Customer ID "AROUT" to "John
Smith"
UPDATE Customers
SET ContactName = 'John Smith'
WHERE CustomerID = 'AROUT'
Example 42:
Due to an increase in the price of sugar, you must increase the unit
price of all products in the "Confections" category
(Category ID 3) by 3%.
UPDATE Products
SET UnitPrice = UnitPrice * 1.03
WHERE CategoryID = 3
On the next page of the wizard, ensure that the "First row
contains column headings" box is checked (see below). After
checking the box (or verifying that it is checked), click Next.
On the last page of the wizard, type PriceUpdate for the linked
table name. When you are done, click Finish.
At this point, PriceUpdate can be used just like any other table in
the database.
Example 43:
Update the unit price data in the Products table with data for the
corresponding products in the PriceUpdate spreadsheet.
Example 44:
Mario Pontes from the Hanari Carnes company calls to tell you to
remove the Manjimup Dried Apples from the order that was placed
on August 8, 1994. You determine that this is order ID 10250 and
that the product in question is Product ID 51.
DELETE Products.*
FROM Categories INNER JOIN Products
ON Categories.CategoryID =
Products.CategoryID
WHERE Categories.CategoryName =
'Beverages'
The INSERT INTO statement has two basic formats. To insert one
row into a table, you can use the INSERT INTO ... VALUES format;
to insert multiple rows into a table from another table, you can use
the INSERT INTO ... SELECT format. The INSERT INTO ...
VALUES format will be shown first.
Example 45:
Insert a record for our new shipper, International Parcel Service.
Their phone number is (800) 888-9999.
Note that in the INSERT statement above, the ShipperID was NOT
specified. This is because the ShipperID field is
defined as an Autonumber field, thus, whenever a
new record is added to the Shippers table, the
ShipperID field will automatically populate with the
next available number.
In the next example, we will use the SQL DDL statement CREATE
TABLE to create a new table. Then we will use INSERT INTO with
the SELECT option to populate this new table with some data from
the Customers table.
The Access SQL CREATE TABLE command has this basic syntax:
(Note: If CHAR or CHARACTER is used, a fixed-length text field is established; this is the only way
a fixed-length text field can be defined. In the Access UI, Text fields are always variable-length and
there is no way to specify otherwise there.)
size The field size in characters (Text fields only). If size is omitted for a Text field, 255 is the default.
NOT NULL Specifies that the field may not contain NULL values (an entry is required)
single-field This clause has the following syntax:
CONSTRAINT
clause CONSTRAINT constraint-name {PRIMARY KEY | UNIQUE | NOT
NULL |
REFERENCES foreigntable [(foreignfield1, foreignfield2)]}
If PRIMARY KEY or UNIQUE is specified, an index of that type is established for this field. NOT
NULL can either be specified as a named constraint or as a stand-alone clause (as seen above).
The REFERENCES option establishes this field as foreign key, related to the primary key in another
table.
multiple-field This clause has the following syntax:
CONSTRAINT
clause CONSTRAINT name {PRIMARY KEY (primary1[, primary2 [,
...]]) |
UNIQUE (unique1[, unique2 [, ...]]) |
NOT NULL (notnull1[, notnull2 [, ...]]) |
FOREIGN KEY (ref1[, ref2 [, ...]])
REFERENCES foreigntable [(foreignfield1 [, foreignfield2
[, ...]])]}
Example 46:
Create a new table called US_CUSTOMERS, which has the same
structure as the existing Customers table.
If you click the design button, you'll see how the fields have been
set up based upon what has been coded in the CREATE TABLE
statement. Note that the CustomerID field has been designated as
the primary key and that by specifying NOT NULL for
CompanyName, the Required property is set to "Yes".
Example 47:
Populate the US_CUSTOMERS table with data from the Customers
table. Include only those rows for which Country is "USA".
Adding a Column
Example 48:
Add a one-character field called CUSTOMER_TYPE to the
US_CUSTOMERS table.
Deleting a Column
Example 49:
Drop the Fax column from the US_CUSTOMERS table.
Example 50:
Drop the primary key constraint from the US_CUSTOMERS table.
(Recall from the CREATE TABLE statement that we named that
constraint PrimaryKey.)
Example 51:
Add the primary key constraint back to the US_CUSTOMERS table.
Deleting a Table
Example 52:
Get rid of the US_CUSTOMERS table.
This last example shows you how you can generate an entire
database structure using CREATE TABLE statements. This
exercise has you build your own version of the BIBLIO.MDB
database that comes with both Access and VB. (If you do not have
BIBLIO.MDB, you can download it here.)
Author TEXT(50),
Name TEXT(50),
Address TEXT(50),
City TEXT(20),
State TEXT(10),
Zip TEXT(15),
Telephone TEXT(15),
Fax TEXT(15),
Comments MEMO);
(Title TEXT(255),
Description TEXT(50),
Notes TEXT(50),
Subject TEXT(50),
Comments MEMO);
Examine your results in the tables' design view and in Tools ->
Relationships.
Post to Facebook
Post to Twitter
Add to LinkedIn
Post to Delicious
Post to Digg
Post on Google Buzz
Add to Google Bookmarks
Send via Gmail
Share on Google Reader
Add to Evernote
Print with PrintFriendly
Send via Yahoo Mail
Similar links
Getting Extended Info From WAV Files In Visual Basic
Start the Windows Screen Saver Using a Win32 API
Creating PDF files in Visual Basic
Simple Windows API Example
Calling Windows APIs
VB6 Animated Charts (With FusionCharts)
Convert C Strings to VB Strings
Activate Any Window With API
Move The Mouse in VB
Advanced Shell In Visual Basic
Very good, I have sat and worked through all of the examples, I was very impressed with
how comprehensive and easy to understand this was.
***However** *
I Think there is a mistake on Example 48, I know I new to SQL, but I am pretty sure that,
"Example 48:
Should be
I really like you site and I am a genuine user, I am also very pleased with the results.
Andy
reply
Tnat/s good manual, simple Sun, 03/18/2012 - 03:12 Anonymous (not verified)
Tnat/s good manual, simple for understanding, even in fact that my knowledge of english
is quite poor.
reply
Probably the best tutorial Fri, 03/16/2012 - 18:35 Eric from Sweden (not verified)
Probably the best tutorial I've seen around regarding this topic.
reply
reply
reply
Hello,
I have created several tables in Access. I use VB6 to manipulate these tables using SQL
statements.
The LIKE statement is not working, here is the SQL statement, please tell me what is
wrong with it:
Thanks
Aiman
reply
From
recordset.open "Select * From ID where ID like '" & "%" & Text1.Text & "%" & "'
",Database
I used this code if you want to select from textbox where firt and last text don't know
reply
example code
recordset.open "Select * From ID where ID like '" & text1.text & "' ",Database
-------------------------------------------------------------------------------------------------
ehehe
reply
ChrisGT7
reply
I have designed a calculator that would be calculating students GPAs, and i want the
calculator to be saving using Access db with an SQL . Please i want someone to give me
a step by step process od doing it........ my E-mail Address: [email protected]. thanks
reply
Hi, I think you have made a mistake. The line item total shouldn't be :
Format$(UnitPrice * Quantity * (1 + Discount)
Currently this doesn't discount the prices at all; it actually raises them! Instead, it should
be :
Format$(UnitPrice * Quantity * (1 - Discount)
I don't know if this was done on purpose (I don't know why it would be..), so I'm just
putting it out there.
reply
Thanks you for your detail Thu, 04/28/2011 - 03:23 Aung Ko Ko (not verified)
explanation
Dear Sir
Thanks you so much for detail explanation for writing SQL statement in ACCESS.
It would be most appreciated if you also explain about detail explanation for writing micro
in ACCESS.
Thanks
reply
its very good tutorial..thanx Fri, 04/15/2011 - 19:43 only one (not verified)
reply
Thank you so much for your Fri, 04/15/2011 - 17:24 Sivasweety (not verified)
Thank you so much for your SQL Tutorial.... Really useful..... Why the rain in comming
regularly...to help people of world.... because
you people...helping others.... so God satisfied and sending the rain... Thank you....
reply
Sir,
This is a great service .....
May god bless you and your family...
Thank you very much.
Ragards
reply
sql 2005
I need the tutorial for connectivity of vb 6.0 with SQL server 2005. And step by step
process of Adding, Updating the database or Deleting the database value or values on
the button click on the VB form. Please Help ..............
reply
reply
reply
reply
reply
Hi co-members! can any of you help me with a way in which i can encrypt passwords
stored in database so that some one cant get the password even if he/she manages to
open the database that contains the passwords?
reply
dfgdfhyrtgnhjgfffffffffffffffffffnhj
gggggggggggggggggggggggggggghhhhhhhhhhhhhhhgfgfgfgfgfgfgfgfgfhgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfgfhhhhhhhhhhhhhhhhfggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhdffffffffffffffffffffffffgfhfhgfhhhhhhhhhhhhhhhhhfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgffffffffffffffffffffffffffffffffffffffffffffffnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnndc
gftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgftgfthhhhhhhhhhhhhh
reply
stupid fellow
reply
Please tell me how to fetch text box or combobox values in the SQL statements.
I have used this query but it is not working properly
select * from TABLENAME where FIELD = '"& Textbox.text &"'
Thanks in advance,
Rohit
My E-mail ID is - [email protected]
reply
Joining text box for Wed, 12/29/2010 - 09:25 Mrutunjaya (not verified)
search in sql
Try this
Dim Find As String
Find="Select * from TABLENAME where TABLENAME.FIELD = " & "'" & Text1.Text &
"'"
Data1.RecordSource = Find
Data1.Refresh
reply
reply
Very Good! Somehow, you've kept it very simple but very informative.
reply
very helpful =)
reply
about sql and vb Sun, 08/22/2010 - 02:58 dashang makwana (not verified)
reply
I can actually learn it myself. But also, I still need to ask my prof for further explanation.
Though it really REALLY HELPED ME A LOT! You're now my idol man! I'll read the rest.
:) God bless and keep sharing what you know.
reply
It is nice tetorial for SQL in VB its gives a strong Back end for Storages Data thank you
reply
Cheers
Bernard
reply
This tutorial is very useful to me....its allobrate the information correctly............i have
request to provide the sql2000 and vb6 sw ..and coding and explanation for same
project
reply
It was nice but one still Sun, 01/03/2010 - 23:59 Anonymous (not verified)
something missing
Hello Everyone out there, the above tutorial is fabulous but I found something still
missing. I was looking for example:
If the NEW ORDER has been placed and if there 1000 items which are of same catagory
and If the customer orders only for 200 items then to my amazement not find in this vast
SQL information that how the one SELECT or DELETE from the STOCK only 200 items
out of 1000 items to place the order. I know it not very complicated but I really dont have
idea about it as Im newbie to SQL but was expecting the query on this website but I
found hopeless myself. Anyhow if the authors of this website are reading these
comments regularly then please also add the said idea as well. Thank you all.
reply
SELECT TOP 200 FROM Tue, 04/27/2010 - 18:22 Anonymous (not verified)
reply
nice, your pdf link goes to Sat, 11/28/2009 - 12:55 Anonymous (not verified)
nice, your pdf link goes to a lets say, not so nice to my pc site.
reply
reply
This is called "Exact" & Sun, 08/30/2009 - 16:03 zchan (not verified)
reply
reply
really great.
reply
reply
reply
This tutorial is lacking.. why is it all TEXT? Please update this with NUMBER or DATE
fields..
reply
superb man best topic i Mon, 12/15/2008 - 09:16 Anonymous (not verified)
have
superb man best topic i have ever seeen coooooooooooooooooooooooooooooool
reply
elements
Nice content, but you need HTML formatting help. An "H6" element is for a 6th-level
heading, and it uses a small font by default.
reply
question: How do use LIKE function in SQL statement if the string you are trying to locate
contains the character: '
example: SELECT * FROM Table WHERE Field LIKE '%O'Neil%'
Thanks!
reply
the page was very helpful and easy to understand. thank you - good job!
reply
good
reply
gfgfgfgfgfgfgfgfgfgfgfgfgfgfg
gfgfgfgfgfgfgfgfgfgfgfgfgfgfgf
reply
I am so happy for the creator or develoers of this site whom i find it very interested and
very helpful...I do hope that God will give you strength to continue on this work...You light
your world to the people and God will even give you more light...and you will get smarter
as days go....
reply
Excellent.
It is a pity that this was not around when I was learning SQL
Rob
reply
E-mail:
The content of this field is kept private and will not be shown publicly.
Homepage:
Subject:
Comment: *
Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
You can enable syntax highlighting of source code with the following tags: <code>,
<blockcode>. The supported tag styles are: <foo>, [foo].
Word verification: *
(verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new
image will be generated. Not case sensitive.
Preview
Unless otherwise noted, all content on this site and in the source samples is Copyrighted
2011 by the owner of vb6.us. All rights reserved - Contact Information