| Author |
Topic Search Topic Options
|
k_mustard
Newbie
Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
Topic: LIKE Statements Posted: 09 October 2003 at 1:27pm |
Hi,
Im using sql, and i need to be able to call certain colums from an access table. I only need the entries from the column that start with the number 4. This is what i have so far.....
<%If strSQL("Record")like "4*" Then%>
unfortunately it isn't working so hot for me :) If you could get back to me asap to let me know how youd fix it, that would be great!
Thanks, Krista
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 October 2003 at 1:43pm |
|
You need to to that in your SQL statement (well not need to but I would: strSQL = "Select * from yourtable where columnnae LIKE '4%'"
|
|
|
 |
k_mustard
Newbie
Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 October 2003 at 1:48pm |
Michael,
I dont just want only the entries that start with 4...just in a certain area. If i do it in my sql statement, will i be able to use the other entries?? or just the ones that start w/ 4??
Krista
|
 |
Gullanian
Senior Member
Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 October 2003 at 3:35pm |
Well, the % stands for anything else, so:
%4 = search field ends in four 4% = search field starts with four %4% = search field contains four
|
 |
k_mustard
Newbie
Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
|
Post Options
Thanks(0)
Quote Reply
Posted: 10 October 2003 at 6:46am |
Ok, well i have only some work order numbers taht start with a 4 and they are to go under a different circumstance if called on the ASP page. Would i still tell the page to look for the order numbers starting w/ a 4 in the SQL statement??? Or would i just call it in the IF statement??
Krista
|
 |
KCWebMonkey
Senior Member
Go Chiefs!
Joined: 21 June 2002
Status: Offline
Points: 1319
|
Post Options
Thanks(0)
Quote Reply
Posted: 10 October 2003 at 7:08am |
use a different sql query to the Db for each different area.
strSQL = conn.Execute("FIRST SQL QUERY IN THIS AREA")
and then
strSQL = conn.Execute("OTHER SQL QUERY HERE....")
|
 |
michael
Senior Member
Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
|
Post Options
Thanks(0)
Quote Reply
Posted: 10 October 2003 at 7:18am |
And if you are pulling all records and just want to display the ones (in said section) that start with four you would do:
If left(rs("record"),1) = 4 THEN Response.Write rs("record")
Depending on datatype you might have to wrap the 4 in quotes
|
|
|
 |
vshriniwasan
Groupie
Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
|
Post Options
Thanks(0)
Quote Reply
Posted: 10 October 2003 at 3:40pm |
|
Better to do it the way Gullanian said. Being you already know what char your string is going to start with, you can use % wild card to take care of it.
|
 |