Jump to content

How to order by order in other table


AndyPSV

Recommended Posts

Use a JOIN to find the matching records instead of IN (SELECT ...)

$tblsell = PRFX.'sell';
$tblskipped = PRFX.'skipped';

$sql = "SELECT *
    FROM $tblsell AS sel
      INNER JOIN $tblskipped AS sk 
        ON sel.id = sk.id_ AND sk.uid = $u
    WHERE sel.draft = 0
    ORDER BY sk.id" ;       
I've got.

 



    SELECT DISTINCT * FROM '.PRFX.'sell sell JOIN '.PRFX.'followed follow ON follow.id_ = sell.id WHERE draft = "0" AND follow.uid = "'.$u.'" ORDER BY follow.id DESC '.$sql_limit


that orders table, but it messes with the original '.PRFX.'sell ID (exchanging it with the follow.id)

 

How to make it back to the original one?

1. I am not on your payroll and therefore do not respond well to comments like

 

Still waiting for an answer

 

2. I haven't a clue what you are talking about when you say

 

Examples mess my original ID

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.