homepage Welcome to WebmasterWorld Guest from 54.227.34.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
perhaps a rookie question
wel51x



 
Msg#: 4323677 posted 10:13 pm on Jun 8, 2011 (gmt 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?

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4323677 posted 11:49 pm on Jun 8, 2011 (gmt 0)

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?

tangor

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



 
Msg#: 4323677 posted 12:02 am on Jun 9, 2011 (gmt 0)

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...)

wel51x



 
Msg#: 4323677 posted 12:05 am on Jun 9, 2011 (gmt 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

tangor

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



 
Msg#: 4323677 posted 12:51 am on Jun 9, 2011 (gmt 0)

Show me some code and how you intend to display it. Can't help without that... don't know what you're using.

wel51x



 
Msg#: 4323677 posted 6:23 am on Jun 9, 2011 (gmt 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.

coopster

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



 
Msg#: 4323677 posted 2:17 pm on Jun 9, 2011 (gmt 0)

You need to monitor for a change in the language in your application logic and output the language only upon change.

LifeinAsia

WebmasterWorld Administrator lifeinasia us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 4323677 posted 3:55 pm on Jun 9, 2011 (gmt 0)

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.).

wel51x



 
Msg#: 4323677 posted 7:50 am on Jun 10, 2011 (gmt 0)

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

Thanks to all

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved