Jump to content

Recommended Posts

Hey,

 

I have a field in my database which is a text format and shows a string like this:

 

Field name: ranks

 

12,34,252,3,52,3,253

 

Now what i want to do, is order rows in DESC order by the first number only in that sentence... so some how only order by the number before the , symbol. Is that possible in an order by ?

Well the alternative is to have unlimited uknown amount of fields which is deffinately not smart.

 

The list:

12,45,636,346,2

 

Each number represents the score from each week, as you never know how many weeks the person runs for, its inefficient to make a table with:

 

Week1,Week2,Week3,Week4,Week5,Week6 etc

 

The table would have hundreads of columns =/

 

And as you can guess i need to ORDER BY on the first week which would be the first number only.

Doesn't matter. You need more fields, INSERT it into that table. Essentially, that table just holds your fields.

 

For example, the table above can hold the following info -

id    field_name

1      Week 1

2      Week 2

3      Week 3

.

.

.

 

Those will be the fields. Need more, add more. Then back in your other table, you can use the id as reference to the field_name. Read the sticky topics in this forum. There is one for DB normalization.

Hmm think i just had a brain wave when reading your post.. what baout:

 

ID  |  WeekNumer | Score

1  |    1            | 23

1  |      2          | 263

 

 

Thank you ! :) For helping me think out of the box I think this will work now !

 

Cheers Ken !

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.