Jump to content

order by BIG_INT dpesnt work...


megetron

Recommended Posts

Hi, why my query doesnt work and the order doesnt work. instead of ordering by a number its order by a string. here is query:

$sql = " SELECT * FROM p_transaction AS t, p_joinpgm AS j,p_merchant as m";

 

$sql .= "where  AND t_joinpgmid = '$joinid' AND t.t_joinpgmid = j.joinpgm_id

AND j.joinpgm_merchantid=m.merchant_id order by t_id desc";

 

 

Link to comment
Share on other sites

Your query is malformed. Right after the WHERE clause you have an "AND". Run your query through PHPMyAdmin to get it right - then create it in the code.

 

Also, it does look like the fields referenced in the WHERE and ORDER BY clauses have an improper field name. I assume "t_joinpgmid" should be "t.joinpgmid" and "t_id" should be "t.id".

 

I would also suggest using JOINS instead of joining the data in the WHERE clause

SELECT *
FROM p_transaction AS t
JOIN p_joinpgm AS j ON t.t_joinpgmid = j.joinpgm_id
JOIN p_merchant as m ON j.joinpgm_merchantid = m.merchant_id

WHERE t.joinpgmid = '$joinid'

ORDER BY t.id desc

 

And, lastly, list out the fields you need in the SELECT clause rather than using '*'. It's inefficient to be querying data that you won't use

Link to comment
Share on other sites

If you were to run that, you would have this query (view the bold portion)

 

SELECT * FROM p_transaction AS t, p_joinpgm AS j,p_merchant as mwhere  AND t_joinpgmid = '$joinid' AND t.t_joinpgmid = j.joinpgm_id

                    AND j.joinpgm_merchantid=m.merchant_id order by t_id desc

 

add a space after the "m" in the first part or before the "where" in the second part. Also, as Psycho stated, remove the "AND" after the "where"

Link to comment
Share on other sites

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.