skwap Posted March 3, 2013 Share Posted March 3, 2013 (edited) Dear Coders, Iam facing a problem... I have 3 tables files,platforms,resolutions in my database Resolutions Platforms 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 March 3, 2013 by skwap Quote Link to comment Share on other sites More sharing options...
skwap Posted March 3, 2013 Author Share Posted March 3, 2013 Please Help Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 3, 2013 Share Posted March 3, 2013 (edited) 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 March 3, 2013 by Christian F. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 3, 2013 Share Posted March 3, 2013 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'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.