Hi
I am looking for an equivalent to the LOCATE function from MySQL.
I have a query(PHP) that looks like this: - $query="SELECT * FROM table WHERE LOCATE('".$var."', field)> 0 ORDER BY LOCATE('".$var."', field) LIMIT 10";
Any Ideas?
4 17291 rski 700
Expert 512MB
Hi
I am looking for an equivalent to the LOCATE function from MySQL.
I have a query(PHP) that looks like this: - $query="SELECT * FROM table WHERE LOCATE('".$var."', field)> 0 ORDER BY LOCATE('".$var."', field) LIMIT 10";
Any Ideas?
I do not know mysql, but does LOCATE work as regular expressions. If so u can use postgres LIKE (or ILIKE) statement.
This may be a little late, but if I got here from a Google search, other people will, too. So here's an answer:
MySQL locate('substring','long string containing substring')
is equivalent to
PostgreSQL position('substring' IN 'long string containing substring')
I am having a similar problem.
However I wish to use this form:
LOCATE(substr,str,pos)
Can someone offer me a way too do this in postgresql?
(as 'position' does not contain the 'pos' function)
Thanks.
rski 700
Expert 512MB
You can use -
strpos(string, substring)
-
but it takes only two arguments.
You can use strpos with substr and it works lile locate -
locate(to_find,str,pos)=strpos(substr(str,pos),to_find)
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Marek Lewczuk |
last post by:
Hello group,
For everyone who thinks about moving from MySQL to PostgreSQL I have a
realy bad news - It's not worth. Why, You may ask... A few days ago I
have installed and tested PostgreSQL,...
|
by: packrat |
last post by:
I am attempting to build a Bugzilla server on OS X.
All of this is new to me, working with the Perl, MySQL, and Bugzilla,
so I have been
banging my head often.
Software error:
When I run the...
|
by: Joshua D. Drake |
last post by:
Hello,
I think the below just about says it all:
http://www.commandprompt.com/images/mammoth_versus_dolphin_500.jpg
Sincerely,
Joshua Drake
|
by: John Wells |
last post by:
Yes, I know you've seen the above subject before, so please be gentle with
the flamethrowers.
I'm preparing to enter a discussion with management at my company
regarding going forward as either...
|
by: Errol Neal |
last post by:
Hi all,
Not sure if this is a question for a php list or this one, but I'll give it
a shot and
if I am wrong, please do not crucify me. :-)
There is a php based sourceforge project called...
|
by: Marek Lewczuk |
last post by:
Hello,
I have changed DB from MySQL to PostgreSQL. When I have run my
application on PostgreSQL it was disaster - it was much slower than
MySQL...
I have tried to change PG configuration file...
|
by: Chris Travers |
last post by:
Hi all;
A few years ago, I set about porting a PHP application from MySQL to
PostgreSQL, after realizing that MySQL wasn't going to be able to handle it.
In order to do this, I built a light,...
|
by: Richard Huxton |
last post by:
On Thursday 12 February 2004 20:25, Prashanthi Muthyala wrote:
> Hi Richard
Hi Prashanthi - nice to hear from you again. I've taken the liberty of cc-ing
the general list on this, since there...
|
by: Jay |
last post by:
hi people
i am trying to connect to ppstgresql on a debian system using perl . i
am getting the following error .can any one please suggest what has to
be done
install_driver(pg) failed:...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |