Jump to content

SUBSTRING_INDEX not working


Monkuar

Recommended Posts

Code:

 

WHERE num_posts > 20 AND SUBSTRING_INDEX('last_post', '|', 1) > 1

 

IM trying to select my first explode in my last_post column.

 

last_post value =

1342545240|614|11890|Find The Religion Forums So...

 

I am trying to select where num_posts >20 AND last_post > 1343622791

 

 

The query shows no errors, but no results.  Please help, Thanks

 

"1343622791" will stand for whatever timestamp I want to be queried by.  1343622791 Is just an example.

 

 

Link to comment
https://forums.phpfreaks.com/topic/266436-substring_index-not-working/
Share on other sites

Column names are not enclosed within single-quotes. SUBSTRING_INDEX('last_post', '|', 1) is trying to find the | character within the literal string last_post

 

Hmm.. so how can I get the value of my last_post column to get SUBSTRINGED?

 

So If it's finding the literal "last_post" that's not good, lol.  I need it to explode through my last_post column I'm assuming.

 

http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_substring

 

this one seems like it would work but no delimiter?

Also, I closed them with " quotes, still no results but no errors? So weird

 

It's well documented that database, table and field names are never enclosed in quotes; only strings are. There's really no need to repeat it in the documentation for each and every function in the manual.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.