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
https://forums.phpfreaks.com/topic/131615-solved-querying-two-tables-for-a-id/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.