Print Page | Close Window

LIKE Statements

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6289
Printed Date: 31 March 2026 at 1:17pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: LIKE Statements
Posted By: k_mustard
Subject: LIKE Statements
Date 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  




Replies:
Posted By: michael
Date 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%'"

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: k_mustard
Date 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



Posted By: Gullanian
Date 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



Posted By: k_mustard
Date 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



Posted By: KCWebMonkey
Date 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....")



Posted By: michael
Date 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



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: vshriniwasan
Date 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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net