Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - LIKE Statements
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LIKE Statements

 Post Reply Post Reply
Author
k_mustard View Drop Down
Newbie
Newbie
Avatar

Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_mustard Quote  Post ReplyReply Direct Link To This Post 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  

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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%'"
Back to Top
k_mustard View Drop Down
Newbie
Newbie
Avatar

Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_mustard Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
k_mustard View Drop Down
Newbie
Newbie
Avatar

Joined: 09 October 2003
Location: Canada
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote k_mustard Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post 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....")

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
vshriniwasan View Drop Down
Groupie
Groupie
Avatar

Joined: 17 December 2001
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote vshriniwasan Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.