Forum Moderators: coopster

Message Too Old, No Replies

How to filter out a variable with a certain length inside mySQL query

         

irock

10:48 pm on Sep 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to select only the rows with a particular column that has exceeded a certain length. That column (or variable) is defined as TEXT in mySQL table.

"SELECT id, subject, context FROM content where BLAH BLAH"

I don't know what to put following 'where.' Is there a function which I can find out about the length of a TEXT variable? If so, could I embed it into a mysql query like the one above?

Thanks!

san_garrafa

11:16 pm on Sep 9, 2003 (gmt 0)

10+ Year Member



This is a MySQL issue rather than PHP.

Take a look at the LENGTH() function on the MySQL doc, string functions [mysql.com].

Hope you find it useful.

San Garrafa

irock

11:32 pm on Sep 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, but when I tried to do this...

"SELECT id, subject, context, char_length(context) AS contentlength FROM content where contentlength > 200"

The query failed.

Isn't contentlength an integer?

Thanks for the help!

san_garrafa

11:40 pm on Sep 9, 2003 (gmt 0)

10+ Year Member



better try:
"SELECT id, subject, context FROM content where char_length(context) > 200"

irock

11:46 pm on Sep 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RIGHT! How come I didn't think of that?