×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How do I use a keyword in a query??

How do I use a keyword in a query??

How do I use a keyword in a query??

(OP)
I have a table with no index and there are only keywords. Here is the layout:


So there is a keyword I want the value from I have tried

CODE -->

select * from freepbx_settings like %FREEPBX_SYSTEM_IDENT% 

FREEPBX_SYSTEM_IDENT is the keyword

freepbx_settings is the table

I know this should be easy but I am having a brain fart with this. Any help much appreciated!

RE: How do I use a keyword in a query??

It's not sufficient to know the data structure to know what you need, but my first guess would be

CODE

select * from `freepbx_settings` WHERE `keyword`='FREEPBX_SYSTEM_IDENT' 

Besides that your code will just error, I don't get why you even consider using LIKE. LIKE is for pattern matching, that would be useful if there are many keywords that have the same keyword pattern, i.e. having the same prefix or suffix.

Chriss

RE: How do I use a keyword in a query??

(OP)
Thanks Chriss
I only tried Like because it was suggested in some searches I did

CODE -->

select * from `freepbx_settings` WHERE `keyword`='FREEPBX_SYSTEM_IDENT' 

gives me the whole row of info. I just need the value in that row

Thanks

RE: How do I use a keyword in a query??

(OP)
I figured it out

CODE -->

select `value` from `freepbx_settings` WHERE `keyword`='FREEPBX_SYSTEM_IDENT' 

Got me what I wanted.

Thanks for the help Chriss!

RE: How do I use a keyword in a query??

You can still get a broader search, as you may have initially intended, with the LIKE operator.

CODE --> sql

select * from `freepbx_settings` WHERE `keyword` LIKE '%FREEPBX_SYSTEM_IDENT%'; 

RE: How do I use a keyword in a query??

Of course but a more useful usage of like is when you don't know the full keyword, then you can query this, for example:

CODE

select * from `freepbx_settings` WHERE `keyword` LIKE '%PBX%'; 

My guess is that you will get the same record with Spamjim's query and perhaps a few more records with my query. It's still always more straightforward and better to not make LIKE your standard tool to use for any query.

Chriss

RE: How do I use a keyword in a query??

(OP)
Now all I need to do is get this into a variable that I can use. I wish to use it in an email that I have setup. Seems like it should be easy. :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close