View Single Post
  #3 (permalink)  
Old Jul 2nd, 2006, 11:56
spinal007's Avatar
spinal007 spinal007 is offline
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 23
Posts: 1,650
Blog Entries: 1
Thanks: 0
Thanked 4 Times in 4 Posts
Re: Dreamweaver ASP/Vb - Queries

Quote:
Originally Posted by Yofamb
SELECT *
FROM (db_name)
WHERE (what you want to use) LIKE '" & service & "' & '%'
Good, but I thought I'd contribute to this thread and pass on a bit of knowledge...
Code: Select all
SELECT Field1, Field2, Field3
FROM TableName
WHERE ((condition1 OR condition2) AND condition3)
Notes:

1. You can use a * to select all fields in a table but this is not recommended because the query might bring back data you don't need and just slow things down. It's good practice to always specify which fields you need.

2. Conditions...
Generally, conditions are: expression [operator] expression
In addition to the standard ones (equals, less than, etc)
you should also note:
!= Not equals (MS SQL)
<> Not Equals (Access)

You can organize your conditions rather like a mathematical expression. Group conditions as you like using brakets and join condition using OR / AND (There are more but you probably won't need them)

3. The LIKE operator
LIKE will compare two strings almost like the equals sign (=), but it lets
you match a pattern rather than a string.
For example:
LIKE 'a%' will match a string begining with the letter 'a'
LIKE '%a' will match a string ending with the letter 'a'
LIKE '%a%' will match a string that has the letter 'a' in it.
More info here: http://exchange.manifold.net/manifol...E_Operator.htm
Reply With Quote