|
 |
asp_web_howto thread: SQL
Message #1 by "Jonathan Marshall" <jdmarsh2g@h...> on Mon, 08 Apr 2002 13:37:38 +0000
|
|
I have a form with a hidden value of "15F8". This value is passed into the
search criteria
sql statement to match against the database. The database doesn't have a
value of 15F8 just 15F8A, 15F8B, 15F8A&B etc... So I use the sql keyword
LIKE with the * wild card to find whatever after that. That alone isn't
enough to pinpoint a specific record because values in that field aren't
unique in each recordset. The other value passed in the form is a unique ID
number of a device. This is also brought into the sql string and added @ the
end. This will specify the correct recordset.
DEVICE = Request.Form("DEVICE") ' Device is 15F8
TECR = Request.Form("TECR") ' TECR is '15F8B-R012A'
sql = ("SELECT DEVICENO, TECR, TITLE, ID, TECP, PHASE, STATUS, TYPE_FUNDS,
TECCB, TECD, SUB, PROJECT FROM MAIN_CONTROL WHERE MAIN_CONTROL.DEVICENO LIKE
'" & DEVICE & "*'")
sql = sql & " AND MAIN_CONTROL.TECR ='" & TECR & "'"
The statement ends up looking like so...
sql = ("SELECT DEVICENO, TECR, TITLE, ID, TECP, PHASE, STATUS, TYPE_FUNDS,
TECCB, TECD, SUB, PROJECT FROM MAIN_CONTROL WHERE MAIN_CONTROL.DEVICENO LIKE
'15F8*' AND MAIN_CONTROL.TECR='15F8B-R012A'")
When I code into the sql MAIN_CONTROL.DEVICENO LIKE 15F8 <<<< shouldn't this
select all records with 15F8A, 15F8B, 15F8C << records in that given field.
The second value that is suppose to be matched against the database is the
TECR#. Someone please help!!
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Message #2 by Oleg Kapeljushnik <c-oleg.kapeljushnik@w...> on Mon, 08 Apr 2002 09:57:34 -0400
|
|
What Database are you working with ?.
You may try use % instead of * as wildcard
or if you know that its always 5 characters you better use 15F8?
Oleg.
-----Original Message-----
From: Jonathan Marshall [mailto:jdmarsh2g@h...]
Sent: April 08, 2002 9:38 AM
To: ASP Web HowTo
Subject: [asp_web_howto] SQL
I have a form with a hidden value of "15F8". This value is passed into the
search criteria
sql statement to match against the database. The database doesn't have a
value of 15F8 just 15F8A, 15F8B, 15F8A&B etc... So I use the sql keyword
LIKE with the * wild card to find whatever after that. That alone isn't
enough to pinpoint a specific record because values in that field aren't
unique in each recordset. The other value passed in the form is a unique ID
number of a device. This is also brought into the sql string and added @ the
end. This will specify the correct recordset.
DEVICE = Request.Form("DEVICE") ' Device is 15F8
TECR = Request.Form("TECR") ' TECR is '15F8B-R012A'
sql = ("SELECT DEVICENO, TECR, TITLE, ID, TECP, PHASE, STATUS, TYPE_FUNDS,
TECCB, TECD, SUB, PROJECT FROM MAIN_CONTROL WHERE MAIN_CONTROL.DEVICENO LIKE
'" & DEVICE & "*'")
sql = sql & " AND MAIN_CONTROL.TECR ='" & TECR & "'"
The statement ends up looking like so...
sql = ("SELECT DEVICENO, TECR, TITLE, ID, TECP, PHASE, STATUS, TYPE_FUNDS,
TECCB, TECD, SUB, PROJECT FROM MAIN_CONTROL WHERE MAIN_CONTROL.DEVICENO LIKE
'15F8*' AND MAIN_CONTROL.TECR='15F8B-R012A'")
When I code into the sql MAIN_CONTROL.DEVICENO LIKE 15F8 <<<< shouldn't this
select all records with 15F8A, 15F8B, 15F8C << records in that given field.
The second value that is suppose to be matched against the database is the
TECR#. Someone please help!!
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
|
|
 |