homepage Welcome to WebmasterWorld Guest from 54.145.183.169
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

    
how do u show a result once?
union_jack

10+ Year Member



 
Msg#: 57 posted 8:56 am on Sep 28, 2005 (gmt 0)

I am using the below statment to bring back results for towns beginning with A to E.

SELECT * FROM data1 where town between 'A%' and 'E%' ORDER BY town

But because I multipule entries the results are for example:

Aberdeen
Aberdeen
Aberdeen
Abingdon
Abingdon

How do I get it to return just the one result per town?

Thanks for any help?

 

SuzyUK

WebmasterWorld Senior Member suzyuk us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 57 posted 9:40 am on Sep 28, 2005 (gmt 0)

try..
SELECT
distinct FROM data1 where town between 'A%' and 'E%' ORDER BY town
union_jack

10+ Year Member



 
Msg#: 57 posted 9:46 am on Sep 28, 2005 (gmt 0)

mmm.. got an error

Warning: Supplied argument is not a valid MySQL result

Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM golf where town between 'A%' and 'E%'

any ideas

SuzyUK

WebmasterWorld Senior Member suzyuk us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 57 posted 10:05 am on Sep 28, 2005 (gmt 0)

.. sorry try

SELECT DISTINCT 'town' FROM 'data1' where 'town' between 'A%' and 'E%' ORDER BY 'town'

forgot to put in town, but it's the "DISTINCT" that should get your one result.

union_jack

10+ Year Member



 
Msg#: 57 posted 10:35 am on Sep 28, 2005 (gmt 0)

that's got it thanks for your help

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