Re: Selecting my data first
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jake Conk wrote: | Hello, | | I have a table with 2 columns, file_id and owner_id. I want to select | all the files and order by file_id but I want the ones that belong to | me to show up first then everyone elses. Is this possible and how? | | This is what I'm trying to accomplish: | | SELECT * FROM whiles WHERE owner_id=my_id first THEN SELECT * FROM | files ORDER by file_id select * from files where owner_id = you union (select * from files where owner_id != you order by file_id) - -- - Philip M. Gollucci ([EMAIL PROTECTED]) o:703.549.2050x206 Senior System Admin - Riderway, Inc. http://riderway.com / http://ridecharge.com 1024D/DB9B8C1C B90B FBC3 A3A1 C71A 8E70 3F8C 75B8 8FFB DB9B 8C1C Work like you don't need the money, love like you'll never get hurt, and dance like nobody's watching. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.8 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIKI81dbiP+9ubjBwRAuOiAJ9e4kGv1qIUs7CbF5LGv30CaQfZgACdHXFM FKFSw66nKpVqcJDug776TBI= =YQxy -END PGP SIGNATURE- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Selecting my data first
It looks like you can use multiple order by's... SELECT * FROM files ORDER BY owner_id, file_id or something like that... The documentation is really good :) On May 12, 2008, at 2:36 PM, Jake Conk wrote: Hello, I have a table with 2 columns, file_id and owner_id. I want to select all the files and order by file_id but I want the ones that belong to me to show up first then everyone elses. Is this possible and how? This is what I'm trying to accomplish: SELECT * FROM whiles WHERE owner_id=my_id first THEN SELECT * FROM files ORDER by file_id I would suspect this can be accomplished by a sub query somehow but I don't know how. Thanks, - Jake -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424-9337 www.raoset.com [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Selecting my data first
On Mon, May 12, 2008 at 11:36 AM, Jake Conk [EMAIL PROTECTED] wrote: SELECT * FROM whiles WHERE owner_id=my_id first THEN SELECT * FROM files ORDER by file_id Would this work? SELECT * FROM whiles WHERE owner_id = my_id ORDER BY owner_id = my_id DESC, file_id
Re: Selecting my data first
I would do something along these lines: SELECT file_id, owner_id, (owner_id = my_id) as 'mine' FROM whiles WHERE blah blah ORDER BY mine, file_id Jake Conk wrote: Hello, I have a table with 2 columns, file_id and owner_id. I want to select all the files and order by file_id but I want the ones that belong to me to show up first then everyone elses. Is this possible and how? This is what I'm trying to accomplish: SELECT * FROM whiles WHERE owner_id=my_id first THEN SELECT * FROM files ORDER by file_id I would suspect this can be accomplished by a sub query somehow but I don't know how. Thanks, - Jake -- Andy Wallace - CISData - IDX Slave AIM: acmwallace [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]