Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Yahweh

  1. MySQL has a convenient syntax for paging data that looks like this: SELECT * FROM MyTable LIMIT 10, 20 That would select 10 records, starting from record 20, so that it returns records 20 - 30. This is convenient way to page data, without returning anymore rows than than you need.However, MS SQL doesn't appear to support that syntax. What is the equivalent sql code to select any N rows from an arbitrary starting point, without having to create a stored procedure?Thanks in advance
  2. Select an additional field with a random value in it. Use your unique identifier, which I presume you've called ID, as the seed:SELECT Rnd(Table1.ID) as Bunny, * From Table1 ORDER BY Bunny; If you execute a query in forward-only, read only mode, this should work just fine, otherwise you might have some unusual behavior. If you are run this query in one of the dynamic modes and try to sort, then a new set of random values will be generated, and the old ones will be erased (and so will your old ORDER BY).
  3. When you submit a form with a checkbox, it sends an empty string for unchecked boxes and sends the value of checked boxes just like any other form element. Example:animals.asp<form action="process.asp" method="post"><p>What kind of pets do you have:<br>Kitties: <input type="checkbox" name="animal1" value="true"><br>Bunnies: <input type="checkbox" name="animal2" value="true"><br>Puppies: <input type="checkbox" name="animal3" value="true"><br>Fishies: <input type="checkbox" name="animal4" value="true"></p><p><input type="submit" value="Submit"></p></form> Imagine that the user submitted the following data: Kitties [x]Bunnies [ ]Puppies [ ]Fishies [x] The page will send the following querystring: process.asp?animal1=true&animal2=&animal3=&animal4=true So, to put that information into a database, you use something like this: Dim Animal1, Animal2, Animal3, Animal4'The following automatically assign the variables declared above to a boolean'value of True or False based on whether they equal the word "true"Animal1 = Cbool(lcase(Request("animal1")) = lcase("true")) 'Returns TrueAnimal2 = Cbool(lcase(Request("animal2")) = lcase("true")) 'Returns FalseAnimal3 = Cbool(lcase(Request("animal3")) = lcase("true")) 'Returns FalseAnimal4 = Cbool(lcase(Request("animal4")) = lcase("true")) 'Returns True After you determine the value of your checkboxes, you can insert them into your database as usual: Dim Conn, RS, SQLSet Conn = Server.CreateObject("ADODB.Connection")Set RS = Server.CreateObject("ADODB.Recordset")sql = "SELECT * FROM table_to_update WHERE ID = 65"Conn.Open your_connection_stringRS.Open sql, Conn, 3, 3 RS("Animal1") = Animal1 RS("Animal2") = Animal2 RS("Animal3") = Animal3 RS("Animal4") = Animal4 RS.UpdateRS.CloseConn.CloseSet rs=nothingSet conn=nothing
  4. ConnectionStrings.com has a lot of information on the type of connection strings you should use to connect to your database.Basically, to connect to a database, you'll use this code:Dim ConnectionString, Conn, RS, SQLConnectionString = "something here" 'modify this lineConn = Server.CreateObject("ADODB.Connection")RS = Server.CreateObject("ADODB.RecordSet")SQL = "some SQL statement" 'modify this lineConn.Open ConnectionStringRS.Open sql1, Conn, 1, 1 'this opens a database in forward-only, read-only mode 'stuff hereRS.CloseConn.Close'Always set your recordsets and connections to nothing when you're done with themSet rs = nothingSet conn = nothing You only need to open a database connection once per page, and you need to open and close as many recordsets as SQL statements you plan on executing. After you are finished getting your information out of your databae and recordsets, close them immediately and set them equal to nothing to free up server resources.The value of ConnectionString variable depends on what type of database you're connecting to, and where the database is located relative to your ASP scripts.To connect to a MySQL database, use this connection string: ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _ "SERVER=mysqlServer;PORT=3306;DATABASE=myDatabase;" & _ "USER=myUsername;PASSWORD=myPassword;OPTION=18475;" For the part reading SERVER=mysqlServer, set that to the location of your sql server. If your ASP scripts and sqlServer are located on the same domain, then SERVER=localhost works most of the time. If that doesn't work, or if you are connecting to a remote database, just use the location of the sql server. A few examples: 'Connecting to a local database, where your database and scripts are'located on the same serverConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _ "SERVER=localhost;PORT=3306;DATABASE=myDatabase;" & _ "USER=myUsername;PASSWORD=myPassword;OPTION=18475;"'Connecting to remote databaseConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _ "SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase;" & _ "USER=myUsername;PASSWORD=myPassword;OPTION=18475;" The USER and PASSWORD correspond to the username and password of your mySQL account (usually these will be identical to the username and password of your account on the remote server), and the DATABASE corresponds to the name of your database.
  5. Hmmm...I haven't the faintest clue why the code isn't working. However, if it's giving you problems, then just go back to executing two seperate queries like you were doing originally.However, make sure when you response.redirect "resultpage.asp?cid=something", you request("CID") on your resultpage.asp to get the passed value.
  6. If you need help on Login/Signup pages, let me know, and I can certainly help you out on them
  7. Jojay, theres nothign wrong with the code I wrote, because its a copy/paste from one my own sites. However I made the presumption that you were using ADOVBS.inc (most ASP programmers include that file at the top of their pages by default). Without that file, ASP won't recognize some of the constants like AdUseClient and so on.See 4GuysFromRolla FAQ - ADOVBS.inc, its a good thing to get in the habit of using ADOVBS.inc. Just copy this text file to your root directory (save it as adovbs.inc or adovbs.asp), and add <!--#include file="adovbs.inc"--> to the top of any page that uses ADO, and then the code I wrote above will work.
  8. Belzar,VBScript as a client-side language is browser specific, it only works on IE. However, client-side VBScript is dead, NO ONE uses anymore. To get a password box that works on all browsers, you have to convert your script to client-side Javascript.However, there is a significant problem with using client-side scripts to password protect pages, namely on the basis that they don't protect anything at all. Anyone can view the source of your page and see everything you've written.Here are 2 ways to password protect pages, but here's a simpler ASP-specific way: <%Dim strPasswordstrPassword = request("password")if Password = "baby" then%> The rest of your page contents should go here.<%else%> <form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post"> What's the password:<br> <input type="password" name="password"> <p> <input type="Submit" value="Go!"> </p> </form><%end if%> Using this code, no one can see any code they shouldn't when they view your source.Alternatively, I like to use this method on my sites:Login.asp: 'You should always use a function like the one below to protect'against SQL injectionFunction SQLSecurity(strString) SQLSecurity = replace(strString, "'", "\'", 1, -1, vbBinaryCompare)End FunctionSub Login Dim Conn, RS, SQL, Redirect Redirect = True Conn = Server.CreateObject("ADODB.Connection") RS = Server.CreateObject("ADODB.Recordset") sql = "SELECT Count(*) as Count FROM my_table WHERE Username = " & _ "'" & SQLSecurity(Request.Cookies("Username")) & "' " & _ "AND Password = '" & SQLSecurity(Request.Cookies("Password")) & "';" Conn.Open my_connection_string RS.Open sql, Conn, 1, 1 if RS("Count") then Redirect = False end if RS.Close Conn.Close set conn = nothing set rs = nothing if Redirect = True then 'if a valid username and password is not found response.redirect "error.asp" end ifEnd Sub On any other page, all I have to do is insert the following two lines at the top of any page: <!--include file="login.asp"-->Call Login... rest of page goes here ... If the user is not logged in, then he or she is automatically redirected to an error.asp page. Otherwise, the page loads as normal.
  9. Jojay,Notice the code that you are using in result.asp: And compare it to the code you're using in resultpage.asp: The querystring you're sending and the querystring you're requesting don't match. Use this instead:[results.asp]response.redirect("resultpage.asp?CID=" & New_id)[resultpage.asp]CID = request.querystring("CID") By the way, you can get the ID of the last inserted query without having to execute another query like this: Dim Conn, RS, SQL, LastInsertedIDSet Conn = Server.CreateObject("ADODB.Connection")Set RS = Server.CreateObject("ADODB.Recordset")Conn.Open your_connection_string rs.CursorLocation = AdUseClient sql1 = "Select * From Your_Table Where 0=1" rs.Open sql1,conn, adOpenStatic, adLockOptimistic RS.AddNew rs("Field1") = Field1_Value rs("Field2") = Field2_Value rs("Field3") = Field3_Value rs("Field4") = Field4_Value rs("Field5") = Field5_Value RS.Update LastInsertedID = rs("CID") RS.closeConn.Closeresponse.redirect "resultpage.asp?CID=" & LastInsertedID After you update your record, and before you close your record, you can assign a LastInsertedID = rs("ID") to get the ID of the field you've just inserted, without having to execute another sql statment.
  10. Its a datatyping issue. VBScript has a tendency to cast variables in the most convenient type with the narrowest bytes, and an integer datatype is about half the bytes as a currency datatype.If you store your database value in another variable, explicitly convert it to a string or a double:Dim myPricemyPrice = cdbl(RS("Price"))'alternately:'myPrice = cstr(RS("Price"))
  11. dhc000531,Nothing is wrong with your server, just your code. You've misspelled your cookie. Observe:<%dim numvisitsresponse.cookies("NumVisits").Expires=date +365numvisits=request.cookies("NumVists")Response.Write("This is a test on initial times of Visits:" &numvisits)If numvisits=" " thenresponse.cookies("NumVisits")=1response.write("Welcome! This is your first time to visite this page")elseresponse.cookies("NumVists") = numvisits +1Response.Write("Welcome! you have visited this")response.write("Web page" &numvisits)If numvisits = 1 thenresponse.write("time before!")else response.write("times before!")end Ifend If%>You're using "NumVists" when you should be using "NumVisits".Here is a re-write of your code: <%Option Explicitdim NumVisitsResponse.Cookies("NumVisits").Expires = DateAdd("m", 12, Now())NumVisits = Request.Cookies("NumVisits")Response.Write "This is a test on initial times of Visits: " & numvisitsIf cstr(numvisits) = "" then response.cookies("NumVisits") = 1 response.write("Welcome! This is your first time to visite this page")else response.cookies("NumVisits") = NumVisits + 1 Response.Write("Welcome! you have visited this ") response.write("web page " & NumVisits) If numvisits = 1 then response.write(" time before!") else response.write(" times before!") end Ifend If%> See a demonstration of the above code is available here:http://www.fstdt.com/scripts/cookie/visits.aspJustsomeguy, That's not quite right, I set and retrieve cookies on the same page all the time.Here's an example of setting and retrieving cookies on the same page:<% Option Explicit %><html><head> <title>Cookies!</title></head><body><p>This is an example of a script that sets a cookie, and retrives it on the same page. The cookie we'll be creating will be called <code>Bunny</code>. The current value of <code>Bunny</code> is:<blockquote> <hr> <%=Server.HTMLEncode(Request.Cookies("Bunny"))%> <hr></blockquote></p><p><form action="default.asp" method="post"> Type a value into the textbox below. It will be used to set the <code>Bunny</code> cookie:<br> <input name="txtCookie" type="Text" value=""><br> <input type="Submit" value="Set Cookie"></form></p><%Dim strCookiestrCookie = Request("txtCookie")If cstr(strCookie) <> "" then 'Setting the cookie Response.Cookies("Bunny") = strCookie Response.Cookies("Bunny").Expires = DateAdd("m", 12, Now())%><p>Here is the new value of <code>Bunny</code>:<blockquote> <hr> <%=Server.HTMLEncode(Request.Cookies("Bunny"))%> <hr></blockquote>Notice that the cookie was set and retrieved on the same page, even after the headers for the page had already been sent.</p><%End if%></body></html> See a demonstration of that code here:http://www.fstdt.com/scripts/cookie/default.asp
  12. I don't recommend creating a seperate "Total" field, it creates too much overhead. Your database structure should look like this:your_table---------------ID (autonumber)Item (text)Price (currency)Quantity (int) Here is some sample data: ID Item Price Quantity1 Cat $12.00 112 Bunny $6.99 133 Mouse $3.99 454 Dog $16.95 75 Horse $34.99 52 You can write an SQL statement to calculate the totals automatically, like this: SELECT ID, Item, Price, Quantity, (Price * Quantity) as TotalFROM Table1; Use this code to display all of the records in your table, with automatically calculated Total: <%Dim RS, Conn, DSNName, SQLSQL = "SELECT ID, Item, Price, Quantity, (Price * Quantity) as Total FROM your_table;"DSNName = "Driver={Microsoft Access Driver (*.mdb)};Dbq=database_path;" & _ "Uid=database_username;Pwd=database_password;" 'leave these alone 'if your database isn't password protectedSet Conn = Server.CreateObject("ADODB.Connection")Set RS = Server.CreateObject("ADODB.RecordSet")Conn.Open DSNNameRS.Open SQL, Conn, 1, 1%> <table> <tr> <th>ID</td> <th>Item</td> <th>Price</td> <th>Quantity</td> <th>Total</td> </tr><% Do until rs.eof response.write "<tr>" response.write "<td>" & RS("ID") & "</td> response.write "<td>" & RS("Item") & "</td> response.write "<td>" & RS("Price") & "</td> response.write "<td>" & RS("Quantity") & "</td> response.write "<td>" & RS("Total") & "</td> response.write "</tr>" rs.Movenext Loop%> </table><%Conn.CloseRS.CloseSet Conn = nothingset RS = nothing%> The output for that script will look somewhat like this: ID Item Price Quantity Total1 Cat $12.00 11 $132.002 Bunny $6.99 13 $90.873 Mouse $3.99 45 $179.554 Dog $16.95 7 $118.655 Horse $34.99 52 $1,819.48 I don't recommend using Access databases. Use MySQL or SQL Server (if you choose to use one of those databases, then the same code above will work, only you'd have to use a different connection string).
  13. Yahweh


    .asp are Classic ASP pages which are written in VBScript, and .aspx are ASP.Net which are written in VB.Net and C#. ASP.Net pages use the .Net framework and are not fully backwards compatible with Classic ASP pages.
  14. Make sure you have read and write permissions on your folders, chmod them to 660 or rw-rw--.
  15. Yahweh

    Games in ASP

    You can't really make truly interactive games, such as a racing game or a fighting game or anything that requires the screen to react to keyboard commands. Unless you have some *very* sophisticated AJAX, all ASP processing takes place on page loads, so anytime you'd perform an action you would require a user to click a button or link to refresh the screen.At best, you could reproduce something like a Zork-styled game or an old-school Myst type game. Its possible to create board games, but reloading the screen on every move wouldn't be very fun for the user. Java and Flash are more appropriate for interactive games.
  16. Yahweh


    Generally, ASP is good because it makes the transition to .Net much easier. The future of web development is going to be .Net, and ASP is generally a move in the right direction if you want to transition to .Net.And in general, ASP is a more straightforward language. Its easy for humans to read, and it has a much cleaner syntax and it promotes good programming habits, at least much better than PHP. For instance, in ASP you should always use Option Explicit to force variable declaration (it also makes programs run faster), a feature lacking in PHP.In my experience, I found using regex is 1000x easier to do in ASP than in PHP. There is a single regex object, a Match and Matches collection, where all regular expressions are implemented in pretty much the same way, and they give the same output. PHP has 11 regular expression functions (ereg, ereg_replace, eregi, eregi_replace, mb_ereg, mb_ereg_replace, mb_eregi_replace, preg_match, preg_match_all, preg_replace), which are variably case sensitive or insensitive and variably return results as arrays or strings. Not fun at all. ASP.Net's regular expressions are even more powerful, especially with balanced groups and named captures (w00t!).Part of the reason why PHP has so many functions is its lack of function overloading. Rather than overload functions for case sensitive and insensitive, or better yet add an additional parameter to specify insensitivity, PHP just creates more functions. As a consequence, PHP has roughly 5000 built-in functions, compared to ASP which has around 200. PHP functions tend to have absurdly long names, averaging about 13 characters, compared to ASP whose functions tend to be around 7 characters. PHP keeps growing when they should really be focusing on creating a language that minimizes overhead, and reducing the overall number of functions to as few as needed to get the job done.Similarly, ASP's XML support is about 1000x easier to do. PHP has 31 functions for XML parsing, compared to ASP which has a single XMLDOM object and ServerHTTPXML object.A lot of people like PHP because its easy to use databases, but I didn't find that to be the case at all. There are 20 functions to connect to databases, which should be weighed against the "magic quotes" problems, and its tendency for global variables to open to script injection. ASP on the other hand other hand supports parameterized queries, rather than explicity stating SQL statements, so its much more secure and doesn't suffer from "magic quotes" when updating or adding new records.With ASP being replaced by ASP.Net, a huge problem is PHP's tendency to enforce spagetti code.I've never liked programming in PHP, its no fun at all. PHP is fine for small projects, or projects where there is relatively little intricacy. Small to medium-sized projects are ideal for ASP, and medium to industrial-sized projects are good for ASP.Net.Probably, the reason why people use PHP in first place, is that its weaknesses are made up for its price: completely free. ASP is a Windows technology, which some people consider is enough reason not to use it. Generally, however, PHP and ASP hosting is identical in terms of price and server quality.I use ASP because, above all else, I can make it do what I want much faster and much more easily.With JSP, its syntax is very similar to C#, but it just doesn't have a very large community. There are lots of PHP and ASP development communities, but not so many JSP communities. C# has really taken off, so if you'd like to use a C-like language, I recommend C#; however, you can use ASP to interpret JScript, which is to C# what ASP is to ASP.Net, although most ASP tutorials are written in VBScript rather than JScript.
  17. Yahweh

    asp file contents

    Looks good.I'm not sure how you did your code, but here's a really simple RSS reader in Classic ASP that uses XLS transformation:http://dotnetjunkies.com/WebLog/nettricks/...02/11/6992.aspx
  18. No worries.I figured out a solution, but it seems odd:<%@ Page Language="VB" Explicit="True" %><%@ Import namespace="System.Text.RegularExpressions" %><script runat="server"> Public Function GetFileName(strString) Dim re as Regex = New Regex("[^a-zA-z0-9]") strString = "cache" & Re.Replace(strString, "_") & ".html" 'On the first pass, /article.asp?id=50〈=en becomes 'cache_article_aspx_id_50_lang_en.html re = New Regex ("_aspx") strString = re.Replace(strString, "") 'On the second pass, cache_article_aspx_id_50_lang_en.html becomes 'cache_article_id_50_lang_en.html GetFileName = strString End Function Sub Page_Load (sender as Object, e as EventArgs) lblRegex.Text = GetFileName(request.ServerVariables("SCRIPT_NAME") & _ "?" & request.ServerVariables("QUERY_STRING")) End Sub</script><html><head></head><body> <form runat="server"> <asp:Label id="lblRegex" runat="server" /> </form></body></html> That gives the results I want, but I'm not sure if its proper code. Should I be using the New keyword each time I want a new pattern? (When I omit one or both of the New keywords, I get an error.)It seems like I'm creating two seperate objects, when I only need one. My pages are heavily dependent on Regex and use dozens of different patterns to get the formatting that I want, but I'm not sure if its very good to be creating dozens of new objects (in the ASP version, I only used one Regex object and modified its .pattern property whenever I needed).
  19. I like to reuse objects over and over, and in particular I am trying to create a Regex object whose .pattern property I can modify over and over. Here is a short script I've written:<%@ Page Language="VB" Explicit="True" %><script runat="server">Public Function GetFileName(strString) Dim myRegex as Regex = New Regex("[^a-zA-Z0-9]") strString = myRegex.Replace(strString, "_") & ".html" 'On the first pass, article.asp?id=50〈=en becomes 'article_asp_id_50_lang_en.html myRegex.Pattern = "_asp" strString = myRegex.Replace(strString, "") 'On the second pass, article_asp_id_50_lang_en.html becomes 'article_id_50_lang_en.html GetFileName = strStringEnd FunctionSub Page_Load (sender as Object, e as EventArgs) lblRegex.Text = GetFileName(request.ServerVariables("SCRIPT_NAME") & _ "?" & request.ServerVariables("QUERY_STRING"))End Sub</script><form runat="server"><asp:Label id="lblRegex" runat="server" /></form> I am converting a filename to something else for use in a cache system I'm trying to write. If a user visits the page the article.asp?id=50〈=en, then the GetFileName function converts it to "article_id_50_lang_en.html".However, after I make my first replacement, I want to change the pattern to continue doing processing to it to remove a superfluous "_asp". However, I get the following error: How do I make my expression "unprotected", so I can modify my pattern and other regex properties?
  20. I suppose then I'm forced to cache files to disk by writing my own functions. So, how do I (1) read a file as ASCII text and (2) write a file to disk.
  21. Yahweh

    error '80004005'

    File permissions are little different on the internet, you have to make sure both your folder and database have write permissions. Right-clicking and unchecking the "read-only" box won't do anything, you have to chmod whatever folder your database is sitting in, set it to 660 (if that doesn't work, try chmodding it to 777). Most FTP programs will allow you to do that just by right-clicking on the folder and changing its permissions.If the FTP program won't let you chmod folders, then you have to ask your webhost to do it for you. The part that says "0=1" just tells the database not to return any rows, because you're not using them. If you excluded that part, it would force the entire table into the recordset object for no purpose (which is very resource consuming). I just reproduced the same code from your opening post. When you use this:Insert into Cform (Cssn,Cjobno,Cfname,Clname,Cphone,Cemail,Cnotes,Cjobref,Cimmsta,Cposition) values ('"&Cssn&"', ... Its going to insert the "&Cssn&" into your field. You have that string surrounded in both single quotes, and double quotes. Thats just SQL, here are some more examples: Select "&cssn&" From some_table;-> &cssn&Select '"&cssn&"' From some_table;-> "&cssn"Select ""&cssn&"" From some_table;-> "&cssn&"Select ''&cssn&'' From some_table;-> '&cssn&' I put double-quotes around the values because I presumed, from your original SQL, that you wanted the string "&cssn&" inserted into your table. I'm not sure why you did, but I just reproduced the SQL code exactly as I read it. But if you were looking to insert form values and not predefined strings, then yes, you would use rs("Cssn") = Request.form("Cssn")
  22. Open your database and change the field called "NO OF ITEMS" to "NO_OF_ITEMS", and change "ORDER ID" to "ORDER_ID". You can't use spaces in field names.Then change this line of code: rs.Fields("NO OF ITEMS") = totalitmes To this: rs.Fields("NO_OF_ITEMS") = totalitems Change the corresponding rs.Fields("ORDER ID") lines to rs.Fields("ORDER_ID").And here's one more suggestion just to improve performance. Change this line: SQL= "SELECT * FROM ORDER_HEAD;" To this: SQL= "SELECT * FROM ORDER_HEAD WHERE 0=1;" The first select statement gets all the records in all the fields from your table and crams it into a Recordset object, but you aren't using any of those records. With the new SQL statement, you're not returning any records (you don't have to), so you'll have faster execution. You can still add new records just like before, but now you'll just be doing it faster.
  23. Here you go:http://www.w3schools.com/asp/asp_send_email.asp
  24. Yahweh

    asp file contents

    This is actually pretty easy:Dim objXMLHTTP, xml, strText'Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")xml.Open "GET", "http://www.targetsite.com/somefile.xml", falsexml.SendstrText = xml.ResponseTextResponse.write(strText)Set xml = Nothing Alternatively, you can use this: dim xmlDoc, isValid, strText set xmlDoc = server.createObject("Microsoft.XMLDOM") xmlDoc.async = false xmlDoc.load xmlPath isValid = cBool(xmlDoc.parseError.errorCode = 0) if not isValid then response.write "Invalid XML file!" & vbNewline & _ "File: " & xmlDoc.parseError.url & vbNewline & _ "Line: " & xmlDoc.parseError.line & vbNewline & _ "Character: " & xmlDoc.parseError.linepos & vbNewline & _ "Source Text: " & xmlDoc.parseError.srcText & vbNewline & _ "Description: " & xmlDoc.parseError.reason End if strText = xmlDoc set xmlDoc = nothing ASP also has functions that will parse XML automatically for you, if you'd like to use them. See this tutorial.
  25. These are really simple. Its a simple SELECT statement using the Like keyword:Select ID, Name, [i]other columns[/i] FROM your_table WHERE Name Like "%something%"; That will search through your database for all rows where the Name field contains the word "something". The %'s are wildcard characters.I don't know if you MS Access has this feature, but in MySQL and MS SQL you can also execute regular expressions in almost exactly the same way: Select ID, Name, [i]other columns[/i] FROM your_table WHERE Name regexp "something"; Using the "regexp" operator, you don't need the %'s. However, you can do much more sophisticated pattern matching. See MySQL pattern matching (note: MySQL doesn't strictly follow regex standards, it has its own syntax that differs slightly from other regex engines).
  • Create New...