Re: Expressions
Ian O'Rourke wrote: Regarding the following query: SELECT ID,Author,DATE_FORMAT(EntryDate,'%d %m %y'),SectionID,Title,Summary,Content FROM articles ORDER BY EntryDate DESC LIMIT 10 I'm still new to Mysql so I'm not sure on this but I think the problem is with your ORDER BY field. Since you are using the date format function I think the output will not sort correctly. So I think I would try this: SELECT ID,Author, DATE_FORMAT(EntryDate,'%d %m %y') FormatedDate, EntryDate, SectionID,Title,Summary,Content FROM articles ORDER BY EntryDate DESC LIMIT 10 Then just don't use the EntryDate column from the query. It's worth a try. Chris W -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions
On Mon, 19 Jan 2004, Ian O'Rourke wrote: > Regarding the following query: > > SELECT ID,Author,DATE_FORMAT(EntryDate,'%d %m > %y'),SectionID,Title,Summary,Content FROM articles > ORDER BY EntryDate > DESC LIMIT 10 > > Okay, I've looked in the manually up and down, as I know how to do it in > Access, but I can't find it. I want to set an expression so I can give the > Date_Format function a handy name - so it returns the name of the column as > ArticleDate, for instance. > > I'm missing something simple :) SELECT ID,Author,DATE_FORMAT(EntryDate,'%d %m %y') AS something, SectionID, Title, Summary, Content FROM articles ORDER BY EntryDate DESC LIMIT 10 (The AS isn't mandatory, you can just state the alias if you want, the AS can be good for readability, however) cheers, Tobias -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions
rom: "sulewski" <[EMAIL PROTECTED]> > I think you can just put the alias after the field like so, > > select id,author,date_format(entrydate,'%d %m %y') ArticleDate, > SectionId,Title,Summary... > You were correct - the version using AS does not work (I'd tried that before mailing). -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions
I think you can just put the alias after the field like so, select id,author,date_format(entrydate,'%d %m %y') ArticleDate, SectionId,Title,Summary... On Monday, January 19, 2004, at 02:16 PM, Ian O'Rourke wrote: Regarding the following query: SELECT ID,Author,DATE_FORMAT(EntryDate,'%d %m %y'),SectionID,Title,Summary,Content FROM articles ORDER BY EntryDate DESC LIMIT 10 Okay, I've looked in the manually up and down, as I know how to do it in Access, but I can't find it. I want to set an expression so I can give the Date_Format function a handy name - so it returns the name of the column as ArticleDate, for instance. I'm missing something simple :) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions
you were so close http://www.mysql.com/doc/en/SELECT.html SELECT COLUMNNAME AS WHATEVER FROM TABLENAME; Marty Gainty - Original Message - From: "Ian O'Rourke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 19, 2004 2:16 PM Subject: Expressions > Regarding the following query: > > SELECT ID,Author,DATE_FORMAT(EntryDate,'%d %m > %y'),SectionID,Title,Summary,Content FROM articles > ORDER BY EntryDate > DESC LIMIT 10 > > Okay, I've looked in the manually up and down, as I know how to do it in > Access, but I can't find it. I want to set an expression so I can give the > Date_Format function a handy name - so it returns the name of the column as > ArticleDate, for instance. > > I'm missing something simple :) > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions in the select query are case insensitive
Sorry about the double posts... But I forgot something... On Friday 28 November 2003 14.51, Lemasson Sylvain wrote: > Can something be done so that mysql be case sensitive ? If you only need case-sentivitity on selects read this: http://www.mysql.com/doc/en/Case_Sensitivity_Operators.html " The BINARY operator casts the string following it to a binary string. This is an easy way to force a column comparison to be case-sensitive even if the column isn't defined as BINARY or BLOB:" Cheers, Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Expressions in the select query are case insensitive
On Friday 28 November 2003 14.51, Lemasson Sylvain wrote: > Hello, Hi > The first think is that I cannot add a primary constraint on test because > Mysql do not make the difference between 'bla' and 'BLA'. It is case > insensitive. I have the same problem when I do: select * from test where > value='bla'. The select return two lines when just one was expected. The > version of Mysql is 4.1 installed on windows 2000; my my.cnf file is: Read about column types: http://www.mysql.com/doc/en/Column_types.html: "CHAR values are sorted and compared in case-insensitive fashion according to the default character set unless the BINARY keyword is given." ... "VARCHAR values are sorted and compared in case-insensitive fashion unless the BINARY keyword is given." Think it will clear things up for you. Mike -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]