Welcome to WebmasterWorld Guest from 54.166.245.10

Forum Moderators: open

Message Too Old, No Replies

perhaps a rookie question

     
10:13 pm on Jun 8, 2011 (gmt 0)

New User

5+ Year Member

joined:June 8, 2011
posts: 6
votes: 0


Hello all,

I have the following table (and I'm sorry, but I can't figure
out how to do ficed width on the board; " || " denotes column
delimiter):

Country || Language || Population
United States || English || 298213000
France || French || 65446000
Mexico || Spanish || 107029000
United Kingdom || English || 59668000
Argentina || Spanish || 38747000
Canada || English || 32268000
Morocco || French || 31478000
Brazil || Portugese || 186405000
Philippines || Tagalog || 83054000
Peru || Spanish || 27968000
Ukraine || Russian || 46481000
Isle of Man || English || 77000


I would like to produce the following:

Language || Country
English || Canada
|| Isle of Man
|| United Kingdom
|| United States
French || France
|| Morocco
Portugese || Brazil
Russian || Ukraine
Spanish || Argentina
|| Mexico
|| Peru
Tagalog || Philippines


or even better:

English:
Canada
Isle of Man
United Kingdom
United States

French:
France
Morocco

Portugese:
Brazil

Russian:
Ukraine

Spanish:
Argentina
Mexico
Peru

Tagalog:
Philippines

Any ideas?
11:49 pm on June 8, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14174
votes: 541


I can't figure out how to do ficed width on the board

Me neither. "code" and "pre" should both work, but neither of them does ("code" eats multiple spaces, and "pre" doesn't use a fixed-pitch font).

Anyway, you gotta give a little more detail. Are you working with a specific program and is this the specific block of information you want to tweak? Or are you looking for recommendations on the best data-cruncher for recurring problems similar to this one?
12:02 am on June 9, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7835
votes: 539


What is your data source and what are you using to pull the data, obviously you want to show it,,, :)

Welcome to webmasterworld, wel51x... We can help better if we can see some code you are attempting to use (Perl, PHP, MySql, etc...)
12:05 am on June 9, 2011 (gmt 0)

New User

5+ Year Member

joined:June 8, 2011
posts: 6
votes: 0


I just want to have the language eliminated after the first row retrieved where there are multiple rows with the same language

ie
lang1 || country1
|| country2
|| country3
lang2 || country4
|| country5
lang3 || country6
lang4 || country7
|| country8
12:51 am on June 9, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7835
votes: 539


Show me some code and how you intend to display it. Can't help without that... don't know what you're using.
6:23 am on June 9, 2011 (gmt 0)

New User

5+ Year Member

joined:June 8, 2011
posts: 6
votes: 0


thanks for the welcome.

here's the code (note the table "country" has three columns: Country, Language and Population):

SELECT `Language` , `Country`
FROM `country`
ORDER BY `Language` , `Country` ASC;

This produces the following output:

English || Canada
English || Isle of Man
English || United Kingdom
English || United States
French || France
French || Morocco
Portugese || Brazil
Russian || Ukraine
Spanish || Argentina
Spanish || Mexico
Spanish || Peru
Tagalog || Philippines

NOTE: " || " is used to denote th delimeter - it does NOT appear in the output.

what I want to see is this:

English || Canada
|| Isle of Man
|| United Kingdom
|| United States
French || France
|| Morocco
Portugese || Brazil
Russian || Ukraine
Spanish || Argentina
|| Mexico
|| Peru
Tagalog || Philippines

in other words the 'Language' column appears on;ly in the FIRST row.
2:17 pm on June 9, 2011 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12548
votes: 2


You need to monitor for a change in the language in your application logic and output the language only upon change.
3:55 pm on June 9, 2011 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5702
votes: 88


Not sure if you could accomplish something like this in a single query. You can probably do something easily by looping through the results of your query.

Much easier to do on the application server side (PHP, .NET, etc.).
7:50 am on June 10, 2011 (gmt 0)

New User

5+ Year Member

joined:June 8, 2011
posts: 6
votes: 0


I suspected you couldn't do it with a simple query - will try it with php.

Thanks to all
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members