Jump to content

MYSQL Problem


skwap

Recommended Posts

Dear Coders,

 

Iam facing a problem... 

 

 

I have 3 tables files,platforms,resolutions in my database

 

 

Resolutions

 

res.png

 

 

Platforms

 

pla.png

 

 

 

The table resolutions,platforms may have same file_id.. My aim is to select all the fields from files table using the file_id retrived from resoulutions,platforms table.

 

files must be displayed as distinct because the table platforms,resolutions may retrieve same file_id so it cause to display the files more than one time.

 

 

I want to display files from files table using the file_id

 

 

My Current Query (Its not working)

 

 
$match_resolution = '240x320';
$match_platform = 'Java MIDP 2.1';
 
 
SELECT * FROM files,platforms,resolutions WHERE
files.id=file_id AND resolutions.resolution = '$match_resolution' AND platforms.platform ='$match_platform'

 

iam getting error :  Column 'file_id' in where clause is ambiguous

 

 

Please help me

Edited by skwap
Link to comment
Share on other sites

First off: Post in the correct section the next time, this has nothing to do with PHP code and thus nothing to do in the "PHP coding help" section. I've moved it to the correct thread for you, but I would not assume mods and gurus are going to do it for you in the future.

 

Secondly: Don't nag! 45 minutes is not waiting long enough, and thus it is very rude (and inconsiderate) of you to bump your thread.

 

Thirdly: Read the rules before posting.

 

Thank you.

 

Oh, and read up how to properly JOIN tables.

Edited by Christian F.
Link to comment
Share on other sites

Obviously, adjust to suit your column needs accordingly (untested):

SELECT * FROM files
INNER JOIN platforms ON ( files.id = platforms .file_id ) 
INNER JOIN resolutions ON ( files.id = resolutions.file_id )
WHERE resolutions.resolution = '$match_resolution' AND platforms.platform ='$match_platform';
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.