Jump to content

Explode it inside a query?


Monkuar

Recommended Posts

Here is my query

SELECT id,username,star,color,actions from users WHERE actions >= 1 ORDER BY actions DESC

 

actions field value is "213|1336456267"

 

how can I use mysql to explode so it only reads the first literation of the exploded values, like 213?

 

Is this why people always say you shouldn't store exploded variables? :P

 

Theres gotta be a way tho right?

 

in other words; is there a mysql function that exploded that actions variable in the query with a | to read only the "213" ?

 

 

Link to comment
https://forums.phpfreaks.com/topic/262241-explode-it-inside-a-query/
Share on other sites

 

I dont understand the syntax

mysql> SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2);
        -> 'www.mysql'

 

is www.mysql.com supposed to represent the field name or?

 

 

so something like this:

 

SELECT SUBSTRING_INDEX('actions', '|', 2);

 

?

$db->query('SELECT id,username,star,color,actions from users WHERE actions >= 1 ORDER BY SUBSTRING_INDEX(\'actions\', \'|\', 2) DESC')

 

WOW

 

TOPIC SOLVED!!!

 

Didn't know you could do this, wow I can store alot of information in explodes now and call them.

 

AwesomE!

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.