开发者

Error in phpmyadmin though runs fine in php script

Ok so this one is strange and I'm thinking there must be a problem in my sql query but I don't see anything wrong with it. What is happening is that I have a script that I am running in a php script that retrieves all categories that a user has signed up for as well as how many other people have si开发者_运维知识库gned up for the same category. When I run the query in the php page it is very slow but does return results. I wanted to see what was happening so I went to phpmyadmin to run the same script and it returns the count of the results very fast but then gives me the following error where the results would normally be displayed:

#1064 - You have an error in your SQL syntax; check the manual that corresponds
       to your MySQL server version for the right syntax to use near '' at line 1 

Here is the query:

SELECT t1.category_id, t3.description AS 'Category',
    t1.list_type_id, t2.name, t1.status_id, t2.user_id,
    t2.email, UNIX_TIMESTAMP( t1.record_date ) AS 'RecordDate',
    (
        SELECT COUNT( category_id ) 
        FROM t1_sub
        WHERE t1_sub = t1.job_ctg_id AND
            t1_sub.list_type_id = t1.list_type_id AND
            t1_sub.status_id =44
    ) AS 'MatchingListings'
FROM t1
INNER JOIN t2 ON t2.id_rfp_vendor_data = t1.user_id
INNER JOIN t3 ON t3.type_lookup_id = t1.job_ctg_id
WHERE t1.status_id =43

I am at a loss. The reason for my question is really two fold:

  1. Is there actually something wrong with my query that I am missing?
  2. If not, is the error mysql showing the reason why my script is running slow and that php has some way around this? (Though this seems like an unlikely possibility I just have to ask to be sure)

Thanks!


PHPMyAdmin takes the liberty to slightly rewrite your queries (for example, adds the LIMIT 0,30 clause as to only show the first 30 lines).

Can you enable the query-log and see which query actually gets executed on the server?

If not, try removing elements from the query until it does work. Show us that query. Or show some table definitions?


Do you have spaces in any of your table or column names? If so, enclose them in backticks:

`table name`


What you should do is delete phpmyadmin and promise never to download it again.

Then fire up a command-line mysql prompt, and try the same query. This will tell you whether the query is genuinely bad, or if phpmyadmin was simply trashing it for the perverted pleasure of its misguided authors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜