Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6381511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:24:16+00:00 2026-05-25T02:24:16+00:00

I have a database table with 6 fields that holds information about restaurants: id

  • 0

I have a database table with 6 fields that holds information about restaurants:
id
name
type
category_1
category_2
category_3

There are three “types” of restaurants: gold, silver, and bronze. Gold restaurants are featured on all 3 of their category pages (category_1, category_2, and category_3). Silver restaurants are featured on their top two categories (category_1 and category_2). Bronze restaurants are featured on their first category only (category_1). On my category pages, I need to display all restaurants in those categories, but Feature the restaurants who qualify to be featured (ie, they need to be listed at the top). I’m not sure how to do this with PHP / MySQL. I can query restaurants in the categories just fine, but how do I tell it to put Featured restaurants at the top? This is what I would need to do on the category “Mexican”:

Display all mexican restaurants. Promote Gold restaurants that have “Mexican” listed in any of their category fields, Promote Silver restaurants that have “Mexican” in their top two category fields, and promote Bronze restaurants that have “Mexican” in it’s top category field.

I’ve been thinking of many different ways to do this and can’t figure it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:24:16+00:00Added an answer on May 25, 2026 at 2:24 am

    This should help you out with your existing table structure.
    I’m assuming type contains bronze, silver, and gold in this query.

    SELECT * FROM restaurants 
    WHERE category_1 = 'Mexican' 
      OR (category_2 = 'Mexican' AND type in ('silver','gold'))
      OR (category_3 = 'Mexican' AND type = 'gold')
    ORDER BY Field(type,'gold','silver','bronze'), name asc;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a database table that holds the following fields: product_id | design_id |
I have a database table TravelRequest that contains, amongst other things, the fields SignOffName
I have a database structure that has a Person table which contains fields such
I have a table in database that is having some fields one of which
I have a database table (named Topics) which includes these fields : topicId name
i have some fields in my database table,and a field with phone name ,
I have a table in an Access 2007 database. All fields are of type
I have a database table which holds meta data about images, the field in
I have a table that holds phone calls, with the following fields: ID STARTTIME
I have a database table that holds parent and child records much like a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.