MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 3rd, 2000, 06:30 AM
Niko Niko is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 3 Niko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hello,
my database table has a column "Colour". There you can find different linguistic versions (english, french, german) of the same colour.

Example: red (german: rot; french: rouge)

How do I have to write my query string in MYSQL/PHP in order to get the three versions when asking for "red"?

I have tried the following:

-----------------------------------------
if ($colour == "") {$colour = '%';}
if ($colour == "red") {$colour2 = "rot";}
if ($colour == "red") {$colour3 = "rouge";}

$sql = "select * from table where (colour like '$colour' or colour like '$colour2' or colour like '$colour3')";
-------------------------------------------

I always get the answer " No data found..", but there is some data that should be found.

Please, tell me how to modify this coding to get it run correctly.

Thank you
Niko

Reply With Quote
  #2  
Old April 4th, 2000, 10:15 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
You can make two tables: colours and languages. In the first you put all the colornames for each color and language. In the second you define the languages.

Table Colors
colorID/LangID/ColorName (Primary ColorID, LangID)
1 1 Red
1 2 Rood
1 3 Rot
1 4 Rouge
2 1 Blue
2 2 Blauw
etc.

Table Languages
LangID/Language (Primary: LangID)
1 English
2 Dutch
3 German
4 French
etc.

Now to get all the language names for Red (colorID=1):
select ColorName from Colors where ColorID=1;

Or you make one table with different language fields, and a row for each color:
ColorID/EnglishName/DutchName etc.
1 Red Rood ...

Then select the row you want:
Select * from tablename where ColorID=1 (or where EnglishName='Red');

Just try what suits your needs best.

Peter


Reply With Quote
  #3  
Old April 4th, 2000, 10:22 AM
Niko Niko is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 3 Niko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Peter,

Thank you so much for your help!

Regards
NiKo

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > MYSQL & PHP Query variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway