Re: query problem with GROUP BY and ORDER BY

2002-06-02 Thread Philip Spradling

On Sat, 01 Jun 2002 11:58:38 +0200
Claire Forchheimer [EMAIL PROTECTED] wrote:

I know the answer to the first part at least.  I think you want to use two columns in 
the order by clause, and leave out the group by clause.  As in:

select * from tbl order by apt, name;

I'm afraid its too late at night for me to be able to think about the rest.  I'm sure 
it can be done though.

Philip


 Hi all,
 
 I have a table including two colums: names and apartment numbers:
 
 apt #| name
 --
 1 | Smith Joe
 1 | Smith Anne
 2 | Doe Richard
 3 | Svensen Mike
 3 | Brant Liza
 
 I need to get a list in alphabetical order, but with people in the same
 apt keept together:
 
 Brant, Svensen
 Doe
 Smith, Smith
 
 The difficulty is to get people living in the same apt grouped together.
 
 SELECT * FROM tbl GROUP BY apt ORDER BY name  - will drop the second
 name
 found in each apt!
 
 (The result would be this list:
 Brant
 Doe
 Smith)
 
 I've been banging my head black and blue over this query! Can anyone
 help??!?
 
 
 Two more issues in addition to this query is:
 
 I'm using a PHP statement to find only the lastname in the name field,
 can
 this be done already in the query??
 
 A nice feature would be to only list one name if both lastnames are the
 same in one apt. In other words the list would then look like:
 
 Brant, Svensen
 Doe
 Smith
 
 can  this be done???


-- 
Philip Spradling
Unemployed C/C++/Java/SQL programmer
(Who do you know who could use an experienced, talented but overeducated programmer?)
[EMAIL PROTECTED]  
http:[EMAIL PROTECTED]/

-
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: substitute for sub query with group function

2002-05-12 Thread Philip Spradling

I could be missing something, but what about:

select col1 from t1 where col2 = max(col2);

On Sun, 12 May 2002 23:04:14 +0200
Sabine Richter [EMAIL PROTECTED] wrote:

 Hello,
 
 I just want to get the value of one column in the row where max of
 another col of this table is.
 With the possibility of sub queries I would write:
 
 select col1
 from table t1
 where col2 = (select max(col2)
   from tab1e t2);
 
 
 But how to do it without a sub query?
 Just with 1 statement?
 I find no solution.
 
 Not wanting to believe there is none 
 Sabine
 
 -
 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
 
 

-
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: substitute for sub query with group function

2002-05-12 Thread Philip Spradling

Oh, someone should fix that... I guess it won't let you put a group statement in the 
where clause.

Here is another way.  On the down side, its a bit more roundabout.  On the up side, 
however, I actually tried it and it worked.

select col1 from t1 order by col2 desc limit 1;

-Philip


On Sun, 12 May 2002 23:41:05 +0200
Sabine Richter [EMAIL PROTECTED] wrote:

 Hello Philip,
 
 that was my first choice, too. 
 But no, error : Invalid use of group function
 
 and select col1, max(col2) from table;
 is error 1140: mixing of group cols with non groupĆ¼ cols is illegal
 (That would other sql backends say too)
 
 and other variants of the above like select col1 from table t1, table
 t2 where =max(col2) result in the same error reports
 
 Perhaps someone else has an idea?
 
 Best regards
 Sabine 
 

-
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




undefined references in libmysqlclient.a

2002-05-12 Thread Philip Spradling

I'm trying to link libmysqlclient into a C/C++ program using g++.
But I get the following errors:

/usr/lib/mysql/libmysqlclient.a(my_compress.o): In function `my_uncompress':
my_compress.o(.text+0xaa): undefined reference to 'uncompress'
/usr/lib/mysql/libmysqlclient.a(my_compress.o): In function `my_compress_alloc':
my_compress.o(.text+0x13c): undefined reference to `compress'

I really have no idea what to do here.  I don't even know how to read 
libmysqlclient.a.  Can anyone clue me in?

-- 
Philip Spradling
Unemployed C/C++/Java/SQL programmer
(Who do you know who could use an experienced, talented but overeducated programmer?)
[EMAIL PROTECTED]  
http:[EMAIL PROTECTED]/

-
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