Question On String Comparison In SELECT Statements
question on string comparison in SELECT statements
--------------------------------------------------------------------------------
First off, this is not the standard problem that can be solved by using:
SELECT * FROM table WHERE string LIKE '%abcd%'
It's actually sort of the opposite of that. I'm looking for a query that can take a string variable and will return only rows where the complete string in the relevant column is a string of the variable passed to the query. So for instance, if the variable passed was 'abcd' then...
rows containing only these strings in the relevant column would be returned:
'abcd'
rows containing these strings in the relevant column would NOT be returned:
'abcdefg'
'abcdxyz'
'abcd1234'
'abcde'
'af'
'hijk'
Is there a way to do this with a MySQL query?
Thanks in advance.
View Replies
ADVERTISEMENT
i want to compare two string where one is stored inside acess DB and othe one is input by user! so what is the if statement should be look like!
if (string1==string2){
alert("Same")}
else{
alert("Wrong")}
what wrong with the code above?i try that code but could not work!
View Replies
View Related
I am writing a script that allows a user to edit one record and its fields in a MSSQL database. For the time being I don't mess with the data, I just display what the script thinks should be updated.
Output is below.
Field name => Original Value = New Value submitted by user
Code: ....
View Replies
View Related
I want to select a bunch of records where a certain field is equal to the following.
Code:
if game <> "" thensql = "SELECT DISTINCT game, system FROM wallpaper WHERE system = 'ps2' AND system = 'gba' AND system = 'gf' AND system = 'xbox' AND system = 'xbox360' AND system = 'gba' AND system = 'ds' AND system = 'pc' AND system = 'psp' AND system = 'ps3' ORDER by ID DESC LIMIT 0, 10"
Set rschanmedia = Server.CreateObject("ADODB.Recordset")
rschanmedia.Open sql, conn, 3, 3
The script works fine but when I run it it doesn't display any records at all! Yet when I run a script where system is <> to something it works fine! What's wrong?
View Replies
View Related
I want my website to support multi-lingua, so I add Codepage="65001" in my english website.
However, after adding that, all the string comparison failed (login page, catcha).
I thought I only need to add codepage, then my website will become multi-lingua site Did I miss something?
View Replies
View Related
I'm using an SQL statement like the following:
Code:
INSERT INTO table (field) VALUES (value) SELECT @@IDENTITY AS NewIdent;
If I run it through a command prompt (osql.exe) it works fine - it inserts the data and returns the new identity. However, when I try to pass this through my nifty GetRows() function the stupid thing chokes (it acts like a normal INSERT statement has been passed - "ADODB.Recordset (0x800A0E78) Operation is not allowed when the object is closed." on the line where I try to execute GetRows).
I've looked through my ADO documentation and don't see any reason why this should be happening (since it does return data). Due to the small amount of data, I'm going to just use a plain old RecordSet object, but for my own piece of mind does anyone know why it won't treat the returned @@IDENTITY variable like normal data?
View Replies
View Related
I am working with an ASP app that creates reports based on data in an SQL Server 200 database. There is a web form with select boxes for the user to select their criteria, and based on that an SQL SELECT statement is generated.
One of the requirements is that some fields need to be multiple selections. The output of these fields are in CSV format (One, Two, Three). These values are all alphanumeric, NOT just numeric....
View Replies
View Related
i am trying to get a piece of code that will check a value and then act accordinly - the usual thing with a For loop enclosing IF THEN ELSE loops - heres what i have
Code:
FOR removecounter = 1 to 15
IF removecounter = Session("newoptions") THEN
response.write "THEY ARE THE SAME - NOTHING TO CHANGE<br />"
ELSE
IF removecounter < Session("newoptions") THEN
response.write " NOTHING TO CHANGE <br />"
ELSE
' the only other thing it can be is > Session("newoptions")
response.write "BLANKING THE UNUSED<br /> "
END IF
END IF
NEXT
the Session("newoptions") is a value between 1 and 15 - i simply dont understand why this thing doesnt work
View Replies
View Related
I am doing a scheduling system. The concept i have but i am weak in my programming, therefore i hope that u all can help me on this.
i have a capacity (uph x shift x 7.17) and orderperday (total orderqty per month / total shift per month)
the thing that i am not sure in is, i want to do a comparison it is becoz there is a capacity limit per day. i cannot afford 2 produce overlimit. so if the orderperday > capacity then orderperday - capacity = balance. balance will be bring forward to the next day to produce. then the comparison will be done again. i am not certain on how to do the looping in this context.
View Replies
View Related
I am creating a website that is going to ask the user to enter a date! then
from an access database get all records where a date field is greater then
the date entered! Sounds simple, I do it in vb all the time!
here is my sql line: Select * From Participants WHERE DateJoined > 01/14/07
ORDER BY TournamentID
it updates fine with the date the user has entered! I know in vb I need to
put ## around the date I am comparing! I tried that, I tried %%. still I
am getting all records from the database
View Replies
View Related
I need to compare an IP address to a database that contains ranges for each byte in a potentially "valid" IP.
Columns in the msSQL db are IP1, IP2, IP3 and IP4.
The problem is that one entry in the database may have a range. If I were to query all four columns and concatenate the data, I may get something like this:
12.35.124.12-89
So if a user sends me 4 variables (1 for each byte in IPv4) over a form, how I would I begin to compare this data?
View Replies
View Related
I have problem regarding the Dates. I am storing Expiry date of the item in DB as varchar since I want date to display in the format MM/DD/YYYY HH:MM.
From user I am taking expiry date in dd/mm/yy hh/mm format and then using toLocaleString() function to convert it into string to store in Database. This function stores date in the format
Sunday, May 1, 2005 10:00:00 AM.
Now at the time of displaying items I am comparing this date to current date. I want to display items which has Expiry Date greater than today�s date. But it is not giving proper result. It is showing items whose expiry date is previous than today�s date. So not showing the desired result.
View Replies
View Related
Just wanna ask if any1 noes the method to compare between current date(today) with other date and state out the difference of days in between? and also for current date(today) is it date()?
View Replies
View Related
My name is Abhishek. I am writing a code in ASP which wants to access all records from SQL Server database where date lies between 11/24/2004 and 12/20/2004.DateVal is a field in custdate table.Can u reply me ASAP i.e. within 2 hours.
View Replies
View Related
If the 2 variables after comparsion return true, then the statement: This file had been inserted already will be displayed! but currently, there is nothing shown when i execute
ResultSet rs = stmt.executeQuery("SELECT * FROM DATES");
while(rs.next())
{
String date1=rs.getString("Dates");
%>
<%if (date.compareTo(date1)==0)
{%>
<%=("This file had been inserted already!")%>
<%}}%>
View Replies
View Related
I'm comparing a date held in a string with a date held in an access database using an SQL query. However despite tests in which the string and the date held in the database are exactly the same, no matches are found.
Here is my SQL query:
SELECT id, TimesheetDate FROM Timesheets WHERE TimesheetDate=VarDate
The format of the date in the database and the format of the string are exactly the same.
I understand this is because the VarDate variable is a string and not comparable so how do translate the string into a date format the database can make a comparison with? I've tried using CDate() with no luck.
View Replies
View Related
I am doing this here:
dim i
dim j
i = 10
j = 10
If i = j then
But it is giving me a false result...
Any ways to do this comparison so it gives me the proprer result?
View Replies
View Related
I'm looping through database results where I have a date time field in the format: 9/2/2007 6:28:53 AM. What I'm trying to do is flag entries that are within the next 12 and 24 hours with a different color. I'm doing this currently with a counter field on another project like this:
PMCOLOR = "#000000"
If cLng(rs("target_current_value")) > cLng(rs("target_value"))- 2800 Then
PMCOLOR = "#FF0000"
End If
If cLng(rs("target_current_value")) > cLng(rs("target_value"))- 1400 Then
PMCOLOR = "#FF9900"
End If
This turns the line red if the current value is within 1400 of target and orange if its within 2800 of target. I want to do exactly the same thing with the date/time field flagging entries red if they are within 12 hours of the current time/date and flagging them orange if they are within 24 hours of current date/time.
I'm not sure how to break down the time and date and compare them to the current time and date, though. Its easy with integers.
View Replies
View Related
I had a script set up to create a redirect until a certain date, and I
left the script in there after that date thinking it would just be
dormant until I changed the date parameters.
To my surprise, it started redirecting again. I must not be clear on how
dates work.
Here is the very simple code:
<%
if date < "8/20/2005" then
response.redirect(url)
end if
%>
View Replies
View Related
I have a site where I need to compare the current date with the clients wedding date. (ie: 3/09/2005 with a wedding date like 6/15/2006) Here is what I'm using now.
CIExpires = DateDiff("d",CurrentDate,WeddingDate)
It will give me either a positive or negative number. I then just use this to either show or hide a link.
If CIExpires <= 0 Then
'don't show link
Else
'show link
end If
What is the best way to do this? The one above just doesn't work.
View Replies
View Related
I am doing a date comparising. Is it possible to compare a selected date with current date which call from date function in VBScript. If can please show me the coding or reference or source online. Or you all have any idea on it?
View Replies
View Related
I am back with another question. I need to have the user input two dates for a date range--thats easy! But now I would like to pull all the files up in a directory that are within that date range. I don't know how to do a comparison on dates.
I already have a working script with a loop pulling up all the files in a directory based on one date entered and listing them ---now I want to make it pull up all the files within this date range---just need to know you can do a date comparison in asp.
View Replies
View Related
I am trying to pick up records from a date range without much luck. For my
example below I am trying to pick up all records made in the last month.
However none are being found (my code is tried and tested for all records).
My database is in Access format. Field "datetime1" is of Date/Time data type
getting the default value by using now()
The relevant part of my code is as follows. Can anyone see what I'm doing
wrong?
View Replies
View Related
I have looked all over the net and even down the back of the sofa but I've been unable to find any scripts that allow me to add price comparison functionality to my shopping cart. where a script might be or even offer some pointers as to how I might go about doing this.
View Replies
View Related
I need some help with some if statements in an asp page I got. My sql statement is:
sql = "select * from courseDesc"
I want to logically diplay all the information on the page. So I inserted this if statement to choose the information I want to dispaly:
<% if rs("courseName") = "whatIsCist" then
response.write(rs("description"))
end if %>
Other courseName titles I need to display the information for further down the page, include: wdt, lan, wan, programming, admissionReq1,2,&3. Does anyone see where my problem is?
View Replies
View Related
I'm having problems getting some ASP code to work with a form I'm using. I'm using the script with a multiple page form and want to print a javascript onsubmit value for just one of the forms. I'm getting errors because of the multiple IF statements and I'm not sure how to do this and have the "s show up properly in the output. Can someone tell me how to do this properly?
Code:
<% If step < 5 Then Response.Write " <form action="/script.asp" method="post" name="theForm" id="theForm" & If step < 1 Then Response.Write " onsubmit=""" & "return checkForm(this);" & End If %> & ">" & End If %>
Here is how I want it to output:
<form action="/script.asp" method="post" name="theForm" id="theForm" onsubmit="return checkForm(this);">
View Replies
View Related
is there a way to use "or, and" statements in asp,
what i want to do it do 2 seperate checks on the database and if one is true or the other one is true then display some text is this possible and also the same check again on the database but the first statement and the second statement has to be true then display some text is this possible, if yes how would i do it?
View Replies
View Related
I have a field on an asp form called hotelYesNo (YesNo value-pulldown) and a field called roomMate.
I want to do an If Then statement likeso: If hotelYesNo = Yes Then roomMate is required, but if hotelYesNo = No Then roomMate is not required.
I don't know how to get this accomplished in the asp code.
I know how to do this in Microsoft Access but not on a webpage.
How would this be done?
View Replies
View Related
I want to run a query and need to use If then statements such as: If this is output, then run this query. Is there a way to do this?
View Replies
View Related
I didn't really get a direct answer in the .net forum so I guess I'll just post it here where it should be anyway. Instead of .net I'm just going to probaly stick with 3.0. I want to have several different templates for users to browse a site in.
Since I can't use include files in ASP is there a way I can ONLY load coding in an if statement as it applys to that certain user? I want to enclose multiple images and coding into one file but only load the ONE image/code that pertains to the user. Is this possible using if statements?
View Replies
View Related
i am trying to find out if three feilds in a record match, if so send it to another page. basically see code.
Quote: rs.Open "Rental", cs, adOpenDynamic
Do Until rs.EOF
If rs.Fields("MemberID").Value=person And rs.Fields("DVDID").Value=dvd And rs.Fields("Current").Value=true then
Response.redirect "copy.asp?memberid=" & person
End If
rs.MoveNext
Loop
this does not bring up a problem just does not do it any ideas on if staemenst etc in asp thingy.
View Replies
View Related
I have a (hopefully) simple question that has been giving me some problems. I'm trying to use a simple Select statement to access some data in an access database. In access, the sql statement is as follows:
SELECT TPL_Checklist_Master.[1] From TPL_Checklist_Master
However, when I try to do this on an ASP Page, it always causes an error. I'm assuming this is because of the [] around the field name 1. (I would change the field names, but I don't have control over that).
I know when trying to use a * in the statement Where field LIKE 'A*' I needed to replace the * with a %. I was wondering if something similar had to be done in this case.
I hope my description is clear enought to follow.
View Replies
View Related
We have currently launched a website in ASP and now want to add some tracking functions.
We have banner ads and emails that we are launching.I would like to create code that will allow me to change the an image and a text link based on where the user is linking in from.
I.e If they clicked on banner xy - then the index page the images would be xy and the text box in another page would be xy. if they clicked on banner zz - then the index page the images would be zz and the text box in another page would be zz.
View Replies
View Related