Jump to content

Recommended Posts

I am currently using this

 

select keyword from ".$mysql_table_prefix."keywords WHERE keyword like '%{$query}%' LIMIT 5

 

to show 5 related keywords to searches done on my search engine.

 

but I also want to query the table query_log and the query column for results, so I need something like this.

 

select keywords.keyword, query_log.query from ".$mysql_table_prefix."keywords, query_log WHERE keyword and query like '%{$query}%' LIMIT 5

 

I know that does not work but I wanted to show some kind of example of what I am trying to do. how can I get the info from both tables? and is there anything I could add to have more relevant related keyword results if more than 5 exist? Like if I use order by something "something being any sql attribute" can I achieve better results? can anyone help me with this? thanks.

Link to comment
https://forums.phpfreaks.com/topic/222189-querying-multiple-tables/
Share on other sites

Does anybody know how I can turn both of these into 1 query?

 

            $result=mysql_query("select keyword from ".$mysql_table_prefix."keywords WHERE keyword like '%{$query}%' LIMIT 3");
            $result=mysql_query("select query from ".$mysql_table_prefix."query_log WHERE query like '%{$query}%' LIMIT 3");

 

Both of those work fine but I need to make it a single query. Can someone please help?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.