Re: [PHP-DB] SQL prob

2005-01-31 Thread Bobo Wieland
Thanks, but DISTINCT doesn't work... But I managed to get it to work 
anyway by including

namn_1 NOT LIKE 'H%'
in the second WHERE-clause...
Micah Stevens wrote:
use DISTINCT?
On Sunday 30 January 2005 12:51 pm, Bobo Wieland wrote:
 

Anyone that can help me with this one? I want this SQL-statement to
retrive only distinct values from the original table column named (not
the AS stuff)
(
SELECT * , namn_2 AS sec_namn, namn_1 AS one
FROM sortiment
WHERE namn_1 LIKE 'H%'
)
UNION (
SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
FROM sortiment
WHERE namn_2 LIKE 'H%'
AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
)
ORDER BY one
LIMIT 0 , 10
this will return, for example, the following row twice where (in the
original table)
namn_1 = Humulus lupulus
namn_2 =  Humle
the two rows are identical except for the sec_namn and one created
by the query. They are set to:
sec_namn  one
HUMLEHumle
HumleHumulus lupulus

_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
   

 

--
_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] SQL prob

2005-01-30 Thread Bobo Wieland
Anyone that can help me with this one? I want this SQL-statement to 
retrive only distinct values from the original table column named (not 
the AS stuff)

(
SELECT * , namn_2 AS sec_namn, namn_1 AS one
FROM sortiment
WHERE namn_1 LIKE 'H%'
)
UNION (
SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
FROM sortiment
WHERE namn_2 LIKE 'H%'
AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
)
ORDER BY one
LIMIT 0 , 10
this will return, for example, the following row twice where (in the 
original table)
namn_1 = Humulus lupulus
namn_2 =  Humle

the two rows are identical except for the sec_namn and one created 
by the query. They are set to:
sec_namn  one
HUMLEHumle
HumleHumulus lupulus


_bobo wieland _ [EMAIL PROTECTED] _
winamp  Not playing anything right now...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] SQL prob

2005-01-30 Thread Micah Stevens

use DISTINCT?

On Sunday 30 January 2005 12:51 pm, Bobo Wieland wrote:
 Anyone that can help me with this one? I want this SQL-statement to
 retrive only distinct values from the original table column named (not
 the AS stuff)

 (
 SELECT * , namn_2 AS sec_namn, namn_1 AS one
 FROM sortiment
 WHERE namn_1 LIKE 'H%'
 )
 UNION (

 SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
 FROM sortiment
 WHERE namn_2 LIKE 'H%'
 AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
 )
 ORDER BY one
 LIMIT 0 , 10

 this will return, for example, the following row twice where (in the
 original table)
 namn_1 = Humulus lupulus
 namn_2 =  Humle

 the two rows are identical except for the sec_namn and one created
 by the query. They are set to:
 sec_namn  one
 HUMLEHumle
 HumleHumulus lupulus




 _bobo wieland _ [EMAIL PROTECTED] _
 winamp  Not playing anything right now...

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



RE: [PHP-DB] SQL prob (DATE_FORMAT)

2002-07-07 Thread Russ

George:

Thanks for that. That's pretty much what I realised anyway, while
composing the email. But I thought I'd send it off anyway!

Thanks a lot.
Russ :-)

-Original Message-
From: George Pitcher [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 05, 2002 2:52 PM
To: PHP DB Mailing List (E-mail)
Subject: Re: [PHP-DB] SQL prob (DATE_FORMAT)


Russ,

I'm a bit of a novice, but I would have thought that the DATE_FORMAT
function would only work if the field had been defined as a DATE field
type.

If you are storing the date as an integer eg: 20020705 (today), why not
format your current date as a variable based on the same method? That
should
produce the same results. You only need to format the output but you can
do
that with PHP.

HTH

George
- Original Message -
From: Russ [EMAIL PROTECTED]
To: PHP DB Mailing List (E-mail) [EMAIL PROTECTED]
Sent: Friday, July 05, 2002 7:33 AM
Subject: [PHP-DB] SQL prob (DATE_FORMAT)


Hi all:

Thanks to Jason for his pointers - whatever the reason though, we need
to use INT(10) for our CMS to work! ;-) Anyways...

Using our MySQL INT(10) field the following query isn't behaving itself:

$event_sql = SELECT *,DATE_FORMAT('EventDate','%Y-%m-%d') FROM events
WHERE EventDate=CURDATE() ORDER BY EventDate DESC LIMIT 3;

This query should only return those event entries of today's date and
any future date right?

The MySQL manual points out that: CURDATE() returns dates thus:
mysql SELECT CURDATE(); -
 '1997-12-15'  (i.e.: with hyphens between the entities in the same
format as my DATE_FORMAT() arg's specify above)
Can anyone point out why the results of the queries continue to output
entries whose dates are prior to the value of CURDATE()? Do these
functions depend upon DATETIME, DATE, TITMESTAMP (etc) MySQL field types
or what??
Cheers all.
Russ


Mr Russ Michell
Web Applications Developer

Itomic.com
Email: [EMAIL PROTECTED]
Tel: +61 (0)8 9321 3844
Fax: +61 (0)8 6210 1364
Post: PO Box 228, Innaloo, WA 6918, Australia
Street: Suite 24, 158 William St, Perth, WA 6000, Australia

No proof of existence is not proof of non-existence.
(Physicist: Stanton T. Friedman on Debunking Ufology)


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


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



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