如何在ASC中使用join来命令和限制sql查询

时间:2017-01-03 15:46:12

标签: sql

我有一个查询按第一个表的id

进行排序
$req = $pdo->prepare("
SELECT a.amt    AS req_amt,
       a.date   AS req_date,
       b.NAME   AS user_name,
       b.status AS user_status,
       b.ref    AS ref_email,
       b.id     AS user_id,
       b.email  AS user_email,
       a.id     AS request_id
FROM   `help_requests` a
       JOIN `users` b
         ON ( a.USER = b.id )
WHERE  b.status = '1'
ORDER  BY a.id DESC 
LIMIT 500
");//ASC

如果我通过DESC订购这个查询,但是如果我把ASC它不会返回任何数据(那就是当我循环没有任何东西出来时就好像我的表行是空的)

0 个答案:

没有答案