Jump to content

[SOLVED] Querying two tables for a id


mogmog

Recommended Posts

Hi, I have a little problem with a SQL query I need which Ive been stuck on for a little while.

 

I have the following tables:

 

games:

g_id

g_title

g_description

 

keywords:

g_id

word

 

What I am doing is creating a search which searches through the games by keywords associated with the game and the game title.

Ive made the php scripts that get the string and breaks it down and creates a SQL query searching for each keyword and if the words are like any g_title. However I receive a invalid sql object error when I run the query. My methods and setup is all ok as other querys run fine.

 

Im just unsure exactly what I am doing wrong with the following query for example:

 

SELECT * FROM games WHERE g_id IN (

SELECT g_id FROM games, keywords WHERE keywords.word="shooter" OR games.g_title LIKE "%shooter%"

)

 

I know the problem is in the nested query as if I remove the "OR games.g_title LIKE "%shooter%"" the uery works fine./

Thanks in advance.

Link to comment
Share on other sites

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.