RE: [PHP] Re: A stupid question...

2002-03-11 Thread Tim Ward

If you mean select by first letter then wild cards are what you want ...
http://www.mysql.com/doc/S/t/String_comparison_functions.html
<http://www.mysql.com/doc/S/t/String_comparison_functions.html> 

in your case "SELECT ... WHERE lastname LIKE '$Letter%' ORDER BY lastname"

... if you mean sort all records but don't sort past the first letter then
"SELECT ..., LEFT(lastname, 1) AS lastname_first ... ORDER BY
lastname_first" or you might even be able to do " ... ORDER BY
LEFT(lastname, 1)" you'll have to experiment with that one.

Tim Ward
Internet chess www.chessish.com <http://www.chessish.com> 

--
From:  Chuck "PUP" Payne [SMTP:[EMAIL PROTECTED]]
Sent:  11 March 2002 02:59
To:  Cary; mysql lists.mysql.com
    Cc:  PHP General
Subject:  Re: [PHP] Re: A stupid question...

I want to sort my a letter in a set colomn. Let say I want to sort
the
colomn last_name

http://www.myserver.com/mysort.php?Letter=A

Like to create a link like A then sort only the last name ore what
ever I
want to sort by that letter.

I hope that's helps. I can order by, but I can't so a sort like the
example
above.

Chuck Payne
Magi Design and Support


on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote:

> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
>> Hi,
>> 
>> I not a newie but I am not a pro at mysql either. I want to do a
query by
>> letter(a, b, c..ect.). Is there a simple way to do it. I am
writing in PHP.
>> So can someone please so me the how.
> 
> 
> I'm not totally sure what your looking for. If you could elaborate
a little
> I am sure that one of us could help you out.
> 
> Cary
> 
> 
> 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [PHP] Re: A stupid question...

2002-03-10 Thread Kim Kohen

G'day Daren

> $query = "SELECT * FROM tbl_name WHERE LEFT(last_name, 1) == '$letter')";
> NOTE: LEFT() is a "special" function, I'd consider it a derivative of
> SUBSTRING()

Does MySQL have a function that can selectively return words from a column?

What I'm looking for is the equivalent of rightwords(text,1) which would
return the rightmost word from text. I'm trying to extract the lastname only
from a column which holds the full name (the data is coming from another
database where the first and last names are combined).

Alternatively, is there a way to parse the names during a LOAD?

cheers

Kim
Sql, query


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: [PHP] Re: A stupid question...

2002-03-10 Thread Demitrious S. Kelly

You haven't given anyone any specifics... nor a link to a phps, so I
cannot be any more specific with my advice


You could probably get away with looking through each of the elements in
the array and using something like 

"
if ( substr($element, 0, 1) == $letter ( {
Stuff();
}
"

at least that's how I would go about it if I wanted a quick fix...

$.002 given ;)

cheers

-Original Message-
From: Chuck "PUP" Payne [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, March 10, 2002 7:04 PM
To: Chuck "PUP" Payne; Cary; mysql lists.mysql.com
Cc: PHP General
Subject: Re: [PHP] Re: A stupid question...

I want to sort by a letter in a colomn. Let say I want to sort the
colomn
last_name. I can do order by but I can do just the A's.

http://www.myserver.com/mysort.php?Letter=A

Like to create a link on a web "A" then sort only the last name are A.
 
I hope that's helps. I can order by, but I can't so a sort like the
example
above.

Chuck Payne
Magi Design and Support


> on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote:
> 
>> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
>>> Hi,
>>> 
>>> I not a newie but I am not a pro at mysql either. I want to do a
query by
>>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing
in PHP.
>>> So can someone please so me the how.
>> 
>> 
>> I'm not totally sure what your looking for. If you could elaborate a
little
>> I am sure that one of us could help you out.
>> 
>> Cary
>> 
>> 
>> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: [PHP] Re: A stupid question...

2002-03-10 Thread Daren Cotter

I would think the easiest way would be to use the string functions of MySQL
itself...then you don't have the overhead of the PHP application having to
check each row of data (a wise person on this board once answered a question
similar to this for me).

Somthing like...

$query = "SELECT * FROM tbl_name WHERE LEFT(last_name, 1) == 'A')";

Using a variable passed in...

$query = "SELECT * FROM tbl_name WHERE LEFT(last_name, 1) == '$letter')";

NOTE: LEFT() is a "special" function, I'd consider it a derivative of
SUBSTRING()




-Original Message-
From: michael kimsal [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 10, 2002 8:17 PM
To: Chuck \ Pup\\ Payne
Cc: mysql lists.mysql.com
Subject: Re: [PHP] Re: A stupid question...


Chuck "Pup" Payne wrote:
> I want to sort by a letter in a colomn. Let say I want to sort the colomn
> last_name. I can do order by but I can do just the A's.
>
> http://www.myserver.com/mysort.php?Letter=A
>
> Like to create a link on a web "A" then sort only the last name are A.
>
> I hope that's helps. I can order by, but I can't so a sort like the
example
> above.
>
> Chuck Payne
> Magi Design and Support


One of two things to do:

When you're inserting the data, figure out the first letter and store
that as a separate column ("letter" perhaps)

Second, probably easier to implement in your case with existing data,
is to use LIKE.

$sql = "select * from datatable where last_name like '$letter%'";

The % is a wildcard symbol, so if $letter is "a" then a last name
of "adams", "aames", "aston", etc. would all match.

I know there's someway to have mysql do a string manipulation to compare
just part of a column's data with something, so you could do something
similar to a 'substr' in PHP - but it's late and I can't remember off
the top of my head.


Hope that helps...


--
Michael Kimsal
http://www.phphelpdesk.com
Taking the ? out of http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [PHP] Re: A stupid question...

2002-03-10 Thread michael kimsal

Chuck "Pup" Payne wrote:
> I want to sort by a letter in a colomn. Let say I want to sort the colomn
> last_name. I can do order by but I can do just the A's.
> 
> http://www.myserver.com/mysort.php?Letter=A
> 
> Like to create a link on a web "A" then sort only the last name are A.
>  
> I hope that's helps. I can order by, but I can't so a sort like the example
> above.
> 
> Chuck Payne
> Magi Design and Support


One of two things to do:

When you're inserting the data, figure out the first letter and store 
that as a separate column ("letter" perhaps)

Second, probably easier to implement in your case with existing data,
is to use LIKE.

$sql = "select * from datatable where last_name like '$letter%'";

The % is a wildcard symbol, so if $letter is "a" then a last name
of "adams", "aames", "aston", etc. would all match.

I know there's someway to have mysql do a string manipulation to compare 
just part of a column's data with something, so you could do something 
similar to a 'substr' in PHP - but it's late and I can't remember off 
the top of my head.


Hope that helps...


--
Michael Kimsal
http://www.phphelpdesk.com
Taking the ? out of http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [PHP] Re: A stupid question...

2002-03-10 Thread Chuck \"PUP\" Payne

I want to sort by a letter in a colomn. Let say I want to sort the colomn
last_name. I can do order by but I can do just the A's.

http://www.myserver.com/mysort.php?Letter=A

Like to create a link on a web "A" then sort only the last name are A.
 
I hope that's helps. I can order by, but I can't so a sort like the example
above.

Chuck Payne
Magi Design and Support


> on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote:
> 
>> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
>>> Hi,
>>> 
>>> I not a newie but I am not a pro at mysql either. I want to do a query by
>>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing in PHP.
>>> So can someone please so me the how.
>> 
>> 
>> I'm not totally sure what your looking for. If you could elaborate a little
>> I am sure that one of us could help you out.
>> 
>> Cary
>> 
>> 
>> 
> 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: [PHP] Re: A stupid question...

2002-03-10 Thread Chuck \"PUP\" Payne

I want to sort my a letter in a set colomn. Let say I want to sort the
colomn last_name

http://www.myserver.com/mysort.php?Letter=A

Like to create a link like A then sort only the last name ore what ever I
want to sort by that letter.

I hope that's helps. I can order by, but I can't so a sort like the example
above.

Chuck Payne
Magi Design and Support


on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote:

> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote:
>> Hi,
>> 
>> I not a newie but I am not a pro at mysql either. I want to do a query by
>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing in PHP.
>> So can someone please so me the how.
> 
> 
> I'm not totally sure what your looking for. If you could elaborate a little
> I am sure that one of us could help you out.
> 
> Cary
> 
> 
> 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php