Tried distinct but does not work ...

mysql

    Next

  • 1. Creating a table of rankings
    In my pilot logbook I fly with lots of different people on different occasions. I like, because I'm a bit sad, to produce a list of who I've flown the most with. Currently I do this with a fairly convoluted method involving creating a temporary table with an auto incrementing column so I get an output a bit like this: Ranking | Name | Hours 1 | Smith | 145 2 | Jones | 135 etc. Is there a way of doing this without having to create and drop temporary tables or is that why temp tables exist in the first place?
  • 2. mysql login
    Hello, When I login to mysql via the commandline, is there a way to check who I am logged in as? Thanks
  • 3. silent crash
    Hi, Since a few months, we have a strange issue with mysql server ( last release for win, on a xp SP2 box ). Randomly, Mysql daemon stops responding. ( estimated frequency : about 1 time per week or per 2 week ) I mean : * No way to connect ( by tcp/ip or by running the mysql command line tool ). * Stop and then restart the Mysql service is unsuccessful. The only "workaround" is to ... reboot the computer ! And then, all's ok for a random duration. When I read the Mysql log, no error is written. I never saw this kind of issue, and so : - I updated Mysql server version. - I replaced the computer which run Mysql for a new one with more memory and cpu ( 512Mo / 1,8Ghz ). So, I'm tired of this issue ... does any one have an idea, something to check ?? Thanks you everybody for any help. Luc.
  • 4. Alter a combination of 2 existing columns as a unique key
    To alter 1 column to a unique key, for example, ALTER TABLE user MODIFY COLUMN id INT NOT NULL UNIQUE; But how to set a combination of 2 columns as a unique key? Individual keys are not unique, but combination is. TIA, James

Tried distinct but does not work ...

Postby user » Wed, 09 May 2007 04:34:16 GMT

Tried distinct however does not work to eliminate repeat output of 
department name. Only want department name to print once with all 
members then next department name and members etc.

select (cccb_name) as 'cccb', CONCAT(member_fname,' ',member_lname) as 
'member ' from member, cccb, member_cccb_lnk where cccb.cccb_id = 
member_cccb_lnk.cccb_id


  Advisory department	 Tom Baster
  Advisory department	 Jim {*filter*}
  Advisory department	 Frank Mustard
  Advisory department	 Julie Trees
  Advisory department	 Jeff Black
  Advisory department	 Louis Chad
  Affirmative Action Department	 Jeff Black
  Approval Department	 Julie Trees
  Development department	 Jeff Black
  Ethics department	 Jim {*filter*}
  Finance department	 Tom Baster
  Finance department	 Tony Tomas
  Finance department	 Jim {*filter*}
  Finance department	 Denny Rest

Re: Tried distinct but does not work ...

Postby strawberry » Wed, 09 May 2007 15:33:52 GMT




This is a problem of data display, as opposed to data retrieval and,
as such, would usually be handled in PHP for instance. However, one
solution was very recently described over at the mysql newbie forum:
 http://www.**--****.com/ ,151726,151939#msg-151939

select if(@prev=cccb_name,'',@prev := cccb_name) as 'cccb',
CONCAT(member_fname,' ',member_lname) as
'member ' from member, cccb, member_cccb_lnk where cccb.cccb_id =
member_cccb_lnk.cccb_id


Re: Tried distinct but does not work ...

Postby user » Thu, 10 May 2007 23:29:39 GMT

I will read your url but I used your sql and it presented a cartesian 
product.







Re: Tried distinct but does not work ...

Postby user » Thu, 10 May 2007 23:51:43 GMT

Ok, the script I provided was incorrect. Following is correct.

select (cccb_name) as 'cccb', CONCAT(member_fname,' ',member_lname) as 
'member ' from member, cccb, member_cccb_lnk where cccb.cccb_id = 
member_cccb_lnk.cccb_id
and member.member_no = member_cccb_lnk.member_no order by cccb asc

However, modified above with your mod and I think it is correct but it 
provides the same out. The cccb is repeated as before.


select if(@prev=cccb_name,'',@prev := cccb_name)  as 'cccb', 
CONCAT(member_fname,' ',member_lname) as 'member '
from member, cccb, member_cccb_lnk where cccb.cccb_id = 
member_cccb_lnk.cccb_id
and member.member_no = member_cccb_lnk.member_no order by cccb asc;


select (cccb_name) as 'cccb', CONCAT(member_fname,' ',member_lname) as 
'member '
from member, cccb, member_cccb_lnk where cccb.cccb_id = 
member_cccb_lnk.cccb_id
and member.member_no = member_cccb_lnk.member_no order by cccb asc;











Re: Tried distinct but does not work ...

Postby Paul Lautman » Fri, 11 May 2007 04:54:10 GMT





It doesn't work because strawberry missed out a very important part of the 
total query when he posted here, although the clue was in the link he posted 
if you looked carefully.
Try:
SET @prev = '';
select if(@prev=cccb_name,'',@prev := cccb_name)  as 'cccb',
CONCAT(member_fname,' ',member_lname) as 'member '
from member, cccb, member_cccb_lnk where cccb.cccb_id =
member_cccb_lnk.cccb_id
and member.member_no = member_cccb_lnk.member_no order by cccb asc;



Re: Tried distinct but does not work ...

Postby user » Sat, 12 May 2007 12:36:23 GMT

orry Paul, but the script still gives me redundant 'cccb' names. I did
look at the url and had added the

SET @prev = ''; and
select if(@prev=cccb_name,'',@prev := cccb_name)

which I think is what your script adds. Anyway, same redundant result.

Thanks anyway


Paul Lautman wrote:

Re: Tried distinct but does not work ...

Postby Captain Paralytic » Sat, 12 May 2007 17:44:00 GMT

n 11 May, 04:36, user < XXXX@XXXXX.COM > wrote:

Itried it on one of my databses and it worked fine.

Can you post the schemas and some sample data (from a phpmyadmin
export so I can load them straight in) and I'll check to see what is
wrong.

Also, please do not top post.


Similar Threads:

1.distinct is not distinct using utf8

Case:
mysql> SELECT  distinct
    ->   MD5(sept_resumen.pabellon),
    ->   sept_resumen.pabellon
    -> FROM
    ->   sept_resumen;
+----------------------------------+-----------------+
| MD5(sept_resumen.pabellon)       | pabellon        |
+----------------------------------+-----------------+
| 0ae9c49b26575e51a1f9fa3b5d03ddce | 5TO.PISO C.P.Q. |
| 60d9463a16418748ab0f23d7927ea197 | Pabellon 1      |
| 25d3e3e2c3b1699708814bc7b1ff48e2 | PABELLON 1      |
| d107d30de2daf4dd3f525b1ba5a72bd7 | Pabell 1      |
| 87907a5fbfa58d9282d92c7e250b5c8e | Pabellon 2      |
| e674b0ac4da1596b8583d92f41d98cf5 | Pabell 2      |
| 340393adf42c54ff32af18380eccabc2 | Pabellon 3      |
| 77ba96970f43973cfd76143ebe9b7ce3 | Pabellon 4      |
| 50c5dec0eff17ec87f471169d7e72ab7 | Pabellon 5      |
| 944a329d737c87c0a5764cfee6010916 | Pabellon 6      |
| 8581233084558fa7e64a9537d477e557 | Pabellon 7      |
| 8d02b147449beedf8b0df0e38264034f | PreAnestesia    |
| acc6830e57d631093ffb0b1f62e5c892 | UCA3            |
| 0e9999073557ade7bbeb28f3194b8980 | UCI             |
+----------------------------------+-----------------+
14 rows in set (0.19 sec)


mysql> SELECT  distinct
    ->   sept_resumen.pabellon
    -> FROM
    ->   sept_resumen;
+-----------------+
| pabellon        |
+-----------------+
| 5TO.PISO C.P.Q. |
| Pabellon 1      |
| Pabellon 2      |
| Pabellon 3      |
| Pabellon 4      |
| Pabellon 5      |
| Pabellon 6      |
| Pabellon 7      |
| PreAnestesia    |
| UCA3            |
| UCI             |
+-----------------+
11 rows in set (0.00 sec)
---------------------------------------------------

Question:
Why is distinct considering 'Pabellon 1' = 'PABELLON 1' = 'Pabell
1' ?

Is there any way to make DISTINCT to work as exact match?

thx
CTP

2.Jobs Failed do not work when scheduled done via DTS Scheduled Package

Hi there,

We found this problem a little odd, jobs that were created using DTS'
Scheduled Package FAILS all the time but if we create a new job manually and
use TSQL under steps it WORKS.

Anything that was done via DTS' FALIS.

Any comments or suggestions is much appreciated.

TIA
DMC


3.DISTINCT not working

I'm using the last version of JDBC driver, and the following query is 
returning duplicate values: 
SELECT DISTINCT COMPANY_ID C1 FROM COMPANY_WORKERS

By if i make de following query, it works:
SELECT A.C1 FROM (SELECT DISTINCT COMPANY_ID C1 FROM COMPANY_WORKERS ) A

Both queries work ok in the SQL Analyzer, but in the code only the second 
one works as espected.

Thanks
Gonalo

4.mdx for distinct count not working!

5.OLAP: Distinct Count does not work in Excel-PivotTable

I have added a additional mesurement by using the "Distinct Ccount" in
my cube, but when I try to pull the data in Excel, it doesn't work in
Excel. Anyone knows why?

(all other measurements are working fine except the one with the
"Distinct Count")

-Harvey

6. PIVOT command do not work for count(distinct xxx)

7. Distributed Transaction Failing on First Try, Second Try Works

8. SQL Statement Not Working (Repost of Criteria Not working but in SQL view)



Return to mysql

 

Who is online

Users browsing this forum: No registered users and 80 guest