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

Link to comment
https://forums.phpfreaks.com/topic/275147-mysql-problem/
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.

Link to comment
https://forums.phpfreaks.com/topic/275147-mysql-problem/#findComment-1416146
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
https://forums.phpfreaks.com/topic/275147-mysql-problem/#findComment-1416258
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.