Click here to Skip to main content
15,396,540 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL SERVER STORE PROCEDURE Pin
Mycroft Holmes28-Apr-22 11:59
professionalMycroft Holmes28-Apr-22 11:59 
GeneralRe: SQL SERVER STORE PROCEDURE Pin
jschell8-May-22 8:07
Memberjschell8-May-22 8:07 
QuestionGiven two dates, count the number of dates in the range that is within month X Pin
Jame_T13-Apr-22 3:43
MemberJame_T13-Apr-22 3:43 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
Craig Robbins13-Apr-22 4:10
MemberCraig Robbins13-Apr-22 4:10 
AnswerRe: Given two dates, count the number of dates in the range that is within month X Pin
CHill6020-Apr-22 7:04
mveCHill6020-Apr-22 7:04 
QuestionBest practice for creating a limited access ms-sql user ? Pin
David Mujica12-Apr-22 11:12
MemberDavid Mujica12-Apr-22 11:12 
AnswerRe: Best practice for creating a limited access ms-sql user ? Pin
jschell8-May-22 8:11
Memberjschell8-May-22 8:11 
QuestionMysql How to sort row ORDER BY another query? Pin
Zac Ang3-Apr-22 10:45
MemberZac Ang3-Apr-22 10:45 
My database tbl_user has the following columns :

    | User_id | Upline | Right_id | Left_id |
    +--------+---------+----------+---------+
    | 1      | 0       |   4      | 7       |
    | 2      | 0       |   6      | 5       |
    | 3      | 0       |   0      | 0       |
    | 4      | 1       |   0      | 0       |
    | 5      | 2       |   0      | 0       |
    | 6      | 2       |   0      | 0       |
    | 7      | 1       |   0      | 0       |
    | 8      | 0       |   0      | 0       |
    | 9      | 0       |   0      | 0       |
    | 10     | 0       |   0      | 0       |  
    +--------+---------+----------+---------+

    $user_id = 2;
    
    $user_tree = $this->getAllRec("u.user_id",  
    "tbl_user u",
    "WHERE u.Upline = '".$user_id."'
    ORDER BY Right_id ASC");
    
    print_r($user_tree);

I want the array `$user_tree` to hold (user_id 5) first, then (user_id 6), how to do that?

I want to print **Left_id** first, then only print **Right_id**. May I know how to do it?

Do I need to use left join or use another query?


modified 3-Apr-22 22:30pm.

SuggestionRe: Mysql How to sort row ORDER BY another query? Pin
Richard Deeming3-Apr-22 21:46
mveRichard Deeming3-Apr-22 21:46 
AnswerRe: Mysql How to sort row ORDER BY another query? Pin
CHill606-Apr-22 2:57
mveCHill606-Apr-22 2:57 
QuestionFilter data before lookup(join) two collections in mongodb Pin
85510-Mar-22 4:20
Member85510-Mar-22 4:20 
Rant[REPOST] Filter data before lookup(join) two collections in mongodb Pin
Richard Deeming10-Mar-22 4:51
mveRichard Deeming10-Mar-22 4:51 
GeneralRe: [REPOST] Filter data before lookup(join) two collections in mongodb Pin
85510-Mar-22 5:23
Member85510-Mar-22 5:23 
GeneralRe: [REPOST] Filter data before lookup(join) two collections in mongodb Pin
Richard Deeming10-Mar-22 6:26
mveRichard Deeming10-Mar-22 6:26 
Question[MySQL] Failed to set datadir Pin
chipp_zanuff1-Mar-22 7:54
Memberchipp_zanuff1-Mar-22 7:54 
AnswerRe: [MySQL] Failed to set datadir Pin
Victor Nijegorodov1-Mar-22 8:39
MemberVictor Nijegorodov1-Mar-22 8:39 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff1-Mar-22 17:42
Memberchipp_zanuff1-Mar-22 17:42 
GeneralRe: [MySQL] Failed to set datadir Pin
Victor Nijegorodov1-Mar-22 22:42
MemberVictor Nijegorodov1-Mar-22 22:42 
AnswerRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan1-Mar-22 22:45
mveRichard MacCutchan1-Mar-22 22:45 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff2-Mar-22 0:35
Memberchipp_zanuff2-Mar-22 0:35 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan2-Mar-22 0:47
mveRichard MacCutchan2-Mar-22 0:47 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff2-Mar-22 23:37
Memberchipp_zanuff2-Mar-22 23:37 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan2-Mar-22 23:44
mveRichard MacCutchan2-Mar-22 23:44 
GeneralRe: [MySQL] Failed to set datadir Pin
chipp_zanuff3-Mar-22 0:30
Memberchipp_zanuff3-Mar-22 0:30 
GeneralRe: [MySQL] Failed to set datadir Pin
Richard MacCutchan3-Mar-22 0:46
mveRichard MacCutchan3-Mar-22 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.