Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 07:51
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  SELECT FROM ... WHERE INSTR(.....)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: SELECT FROM ... WHERE INSTR(.....)  (Read 975 times)
till
Seasoned Programmer
***
Posts: 200



View Profile WWW Email
« on: 08/24/10, 08:25 »

hi!

i' d like to use INSTR within my query.
i searched the web but only information is on http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_instr.  and i dont understand.

This doesnt even give me an error:

$querystring = "SELECT *  FROM $table_images".$pre_fix." WHERE   INSTR(parent_id,'TEST_50') > 1  ";

please tell me whats wrong.
thanks for helping.

till.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 08/24/10, 09:01 »

you should be thinking of a redesign, if you have to search for a fragment of a field.
These are the neverending queries, unless you have a different argument to cut the data down, or have small tables anyway.

but it is relatively easy:
Code:
$querystring = "SELECT *  FROM $table_images".$pre_fix." WHERE  parent_id like '%TEST_50%'";

Btw. If you think of security and performance, never do Select * - allways explicitely name the fileds you are selecting - and allways only select the fields, you want to work with, to keep response small.
Logged

happy flashing
Cool
Ronald
till
Seasoned Programmer
***
Posts: 200



View Profile WWW Email
« Reply #2 on: 08/24/10, 11:36 »

Thanks ronald !

$querystring = "SELECT *  FROM $table_images".$pre_fix." WHERE   INSTR(parent_id,'TEST_50') > 0  ";

gave me the result..... (silly mistake)

but i think this over.

and how do you manage a key-word search in a longtext then ?

till.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #3 on: 08/25/10, 00:18 »

with the LIKE operator.

The percent sign works like the asterisk in DOS/WINDOWS environment.

If you are looking for certain patterns, you should look into regular expressions.
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!