Jump to content

help with query formulation


co.ador

Recommended Posts

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.

 

tableilustration.th.gif

 

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

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.