co.ador Posted November 22, 2009 Share Posted November 22, 2009 hi This query will display all the restaurants fields when the r.foodtypes_id equals rf.foodtypes_id $query3= "SELECT r.* FROM restaurants r INNER JOIN foodtypes rf ON r.foodtypes_id = rf.foodtypes_id "; I am looking for a query where it only displays the restaurants names only when r.foodtypes_id identical or equal to rf.foodtypes_id. example 1 = 1 r.foodtypes_id = r.foodtypes_id then when that conditions happens then it will display only the restaurants names that has 1 as the value for the r.foodtypes_id field. Right now the query will display all the columns and rows of the restaurants table when the condition 1 = 1 r.foodtypes_id = r.foodtypes_id is met and I don't want to display all the name. In the image above I want restaurants "ca" and "tu" display in pagex.php when a user chooses russian food in the table foodtypes.. But right now as the query is it will display all the fields, it's columns and rows... i only want to display selected rows display only when restaurant x when user x chooses, foodtype x? The restaurant x specializes in foodtype x therefore restaurant x will only display in the screen Link to comment https://forums.phpfreaks.com/topic/182523-help-with-query-formulation/ Share on other sites More sharing options...
kickstart Posted November 23, 2009 Share Posted November 23, 2009 Hi Sounds like you are 99% there. Something like this would do it $query3= "SELECT r.name FROM restaurants r INNER JOIN foodtypes rf ON r.foodtypes_id = rf.foodtypes_id WHERE r.foodtypes_id = 1"; All the best Keith Link to comment https://forums.phpfreaks.com/topic/182523-help-with-query-formulation/#findComment-963868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.