Gossamer Forum
Quote Reply
LIKE %%
I'm trying to figure out how to use the MySQL's LIKE option. I have a variable in the SQL database, like;

23 54 23 44 54 23 44

Now, I want to run something like;

SELECT * FROM lsql_Adverts WHERE Field LIKLE '% 54 %'

I've been scanning through the documents, but didn't see anything. Maybe GT should add an internal search engine of the documents for us developers Smile

Thanks to anyone who can help.

BTW: I did search the forum, but didn't yeild much, as I really need to do a case sensative search, but GForum doesnt let you Frown)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] LIKE %% In reply to
If you are trying to figure out "LIKE" then you should be searching at the mysql site, not the GT docs.

Are you looking for how to use it or how to write the GT::SQL equiv?
Quote Reply
Re: [Paul] LIKE %% In reply to
I know how to use LIKE, but I need the GT::SQL equivelant...

Cheers Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] LIKE %% In reply to
Have a look in the documentation for GT::SQL::Condition.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Andy] LIKE %% In reply to
Well be more accurate in your questions because you said:

Quote:
I'm trying to figure out how to use the MySQL's LIKE option.

Tongue

Last edited by:

Paul: Jan 28, 2003, 2:54 AM
Quote Reply
Re: [Andy] LIKE %% In reply to
The mass mailer .pm uses "%_%" with like in several places, you may get an idea of how to do it with complex conditions by looking at that .pm and then setting your debug level 1 and checking your error logs for what the actual submitted query is.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] LIKE %% In reply to
I've just got back to looking into this. I am now using;

my $cond = new GT::SQL::Condition;

if ($query) {
$cond->add(Article => Like => "%$query%");
}

The thing is, does anyone know if you can use multiple fields to search? For example, the above would search the 'Article' field to see if the words exist, but I want it to search both the Article and Title fields.

does anyone have any experience with this?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] LIKE %% In reply to
It should be

$cond->add('Field','LIKE',"%$query%");
Mel Goulet
Developer - Gossamer Threads, Inc.
Quote Reply
Re: [Mel_g] LIKE %% In reply to
Andy's code already does that except using => which prevents you having to quote so much.

Last edited by:

Paul: May 8, 2003, 1:41 PM
Quote Reply
Re: [Paul] LIKE %% In reply to
I've found that doing it with the => 's doesn't always work.
Mel Goulet
Developer - Gossamer Threads, Inc.
Quote Reply
Re: [Andy] LIKE %% In reply to
I don't remember exactly, but my alpha_bar plugin uses "LIKE" to allow for first letter and start of word searches. Might give you some clues.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.