Chanchal Kumari
Chanchal Kumari

Reputation: 45

Forming SQL query

In my android app, I am getting a list of nearby restaurants from Google Place API.

But unfortunately, this list does not give menus of the restaurant.

I have T_RESTAURANT and T_MENU tables.

Lets say, I get 4 restaurants in the list returned by API, then how should I make my query to extract data.

If I do: SELECT name, votes, review FROM T_MENU WHERE restaurant_name = REST_NAME_1;

and I have to fire this query for each of the restaurants i.e. 4 times in this case.

Can anyone suggest me a good solution?

Upvotes: 0

Views: 132

Answers (3)

Joe G Joseph
Joe G Joseph

Reputation: 24046

try this:

select T.name, T.votes, T.review ,M.<menu_items> 
from  T_RESTAURANT R join T_MENU M
where R.restaurant_name=T.restaurant_name

Upvotes: 0

eugenesqr
eugenesqr

Reputation: 579

You can use "IN" keyword instead of "=". A also suggest using restaurant ids instead of names.

Upvotes: 0

hemu
hemu

Reputation: 3261

SELECT name,
       votes,
       review
FROM   T_MENU
WHERE  restaurant_name 
     IN ( <four restaurant names comma separated> ) 

Upvotes: 1

Related Questions