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

  • SEARCH
  • Home
  • 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 6897825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:13:06+00:00 2026-05-27T07:13:06+00:00

I have a table: tbl_offer (offer_name, location). For a particular offer I have more

  • 0

I have a table: tbl_offer (offer_name, location). For a particular offer I have more than one location in location column, separated by commas.

Example:

If offer is offer1 then I have Bangalore, Mumbai, Chennai in the location column.

Now want to write a query which will fetch each location separately (which are separated by commas for a particular offer). I want choose the offer1 it should fetch Bangalore Mumbai and Chennai in separate records.

  • 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-27T07:13:06+00:00Added an answer on May 27, 2026 at 7:13 am

    As @Cylindric told you, if you can change database design!
    Create two tables, one for offers and one for location.

    OFFERS    (id, name)
    LOCATIONS (offer_id, name)
    

    So (for example) you have (1, 'offer1') in OFFERS and
    (1, 'Bangalore'), (1, 'Mumbai') and (1, 'Chennai') in LOCATIONS.

    Your query will be easier:

    SELECT o.name, l.name FROM offers o
    INNER JOIN locations l ON o.id = l.offer_id
    

    To be honest, you should have three tables to avoid locations repetitions:

    OFFERS     (id, name)
    LOCATIONS  (id, name)
    OFFERS_LOC (offer_id, loc_id)
    

    You have
    (1, 'offer1') in OFFERS,
    (1, 'Bangalore'), (2, 'Mumbai') and (3, 'Chennai') in LOCATIONS and
    (1, 1), (1, 2) and (1, 3) in OFFERS_LOC.

    Your query will be

    SELECT o.name, l.name FROM offers o
    INNER JOIN offers_loc ol ON o.id = ol.offer_id
    INNER JOIN locations l ON ol.loc_id = l.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL table called tbl_einheit. phpmyadmin shows more than 14.000 rows in
I have a table tbl_Info : InfoId Text PrivacyTypeId UserName TypeId IsInfo InfoItemId Example
For example, I have a table tbl like values 10 20 30 40 on
I have the following table: tbl_ProductCatg Id IDENTITY Code Description a few more. Id
I have a table with several hundred million rows. One of the columns is
i have 1 table called tbl_Run and only 1 column called wo .the question
I have a table, tbl_english, containing the column word. I also have a table,
I have a table called TBL_CAS. In that, FLD_ID as auto increment column and
i have a table (tbl_world) which look like this id | first_name | last_name
I have a table that contains intervals: CREATE TABLE tbl ( user_id: INTEGER, start:

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.