Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Search Query

Codes here !

Moderators: macek, egami, gesf

Search Query

Postby snigdha » Tue May 15, 2012 10:58 pm

Hi, I wanna solution for retrieving records based on the following criteria:
I have some Restaurants with the cuisines as follows:

Restaurant 1 - Chinese, Japanese
Restaurant 2 - Chinese
Restaurant 3 - North Indian, Mexican, Chinese
Restaurant 4 - Hyderabadi, Chinese

When I perform a filtered Search i.e. if Chinese check box is clicked, I want the records to be displayed in the following order
Restaurant 2 - Chinese
Restaurant 1 - Chinese, Japanese
Restaurant 4 - Hyderabadi, Chinese
Restaurant 3 - North Indian, Mexican, Chinese

that is in Restaurant 2 Chinese is in Order1, in Restaurant 1 Chinese is in Order1 following other cuisine, in Restaurant 4 Chinese is in Order2 and in Restaurant 3 Chinese is in Order3

So can anyone plz help me how to write query for retrieving Search results like the above.
In Restaurants table I have Cuisine Id.
Also tried using separate table for storing Cuisine ID of Restaurants (ie if Restaurant 1 has Restaurant ID 20 and with 2 Cuisines the details will be stored as follows:
Rest Id Cuisine ID
20 45
20 24

Please help me to solve the above...

New php-forum User
New php-forum User
Posts: 1
Joined: Tue May 15, 2012 10:43 pm

Re: Search Query

Postby Nullsig » Thu May 17, 2012 6:53 am

Can you show the structure of the tables you are querying?

The answer will depend on how you are storing the data.
User avatar
php-forum Fan User
php-forum Fan User
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.