Welcome Guest!
Please login
If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:
- Receive Fast Advice
- Learn Programming Languages
- Get Professional Website Reviews
- Quick Troubleshooting Assistance
|
|
Checking If A Value Already Exists
This is a discussion on Checking If A Value Already Exists, within the MySQL section. This forum and the thread "Checking If A Value Already Exists" are both part of the Programming Your Website category.
![]() ![]() |
Jul 17 2008, 05:23 AM
Post
#1
|
|
|
Squeezing ![]() ![]() ![]() Posts: 81 Joined: 18-February 08 |
I have some data like below:
CODE Item Country Product A UK Product A France Product B UK, France Product C Product A is available in a regionalised version for UK and a different regionalised version for France. Product B is available in UK and France, but is not regionalised (both countries get exactly the same product). Product C I don't know what countries it is available in. If an item appears in the database twice (e.g. Product A) then when I output the data to be displayed on the web I need to make it clear what country it came from, so the (sorted) output would look like: Product A (France) Product A (UK) Product B Product C To do this I could check each record as its pulled off the database to see if another record with the same 'item' value exists, but I guess this would be quite intensive when dealing with 100+ records? My thought would be to add another column like this: CODE Item Country Regionalised Product A UK 1 Product A France 1 Product B UK, France 0 Product C 0 Then in the SQL statement to pull the data off if Regionalised is true concat the Country to the Item. Does this sound sensible, or would there be a better way of doing this? Thanks Dave |
|
|
Jul 17 2008, 07:06 AM
Post
#2
|
|
|
Rapid Squeezer ![]() Posts: 308 Joined: 15-February 08 From: Finland |
Don't you want to include the country also to the items which are not regionalized? It's kinda important info to know which countries the product is available? So you could include the country in all products and then use that "new" regionalized field to see if the item is regionalized.
What if the product is regionalised in France but not in UK? I would propably put the data in two tables (products, product_countries, optional third table countries). The middle table would include the country name (or id) where the product is sold and if it is regionalized. How does that sound? -------------------- |
|
|
Jul 19 2008, 01:06 PM
Post
#3
|
|
|
Squeezing ![]() ![]() ![]() Posts: 81 Joined: 18-February 08 |
Thanks for the reply, yep I already have my countries in a seperate table and a lookup table to link the countries to the items.
There will be 2 ways of displaying the data - by country (in which case the item doesn't need the country name appending to it) or by category, in which case 2 items with the same name in the same category will need the country name appending. The items aren't available for sale, its just pics and info on them so I don't think the country name needs appending to all results. The country name is visible anyway when you click on the item for more information. Cheers Dave |
|
|
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
4 | jamesicus | 272 | 6th April 2008 - 11:33 PM Last post by: jamesicus |
|||
![]() |
2 | djeyewater | 167 | 29th April 2008 - 04:05 AM Last post by: djeyewater |
|||






Jul 17 2008, 05:23 AM






