English 中文(简体)
Sql 查询在 Mysql 5.5. 16 版本中不工作
原标题:Sql query doesn t work in Mysql version 5.5.16
  • 时间:2012-05-22 18:21:41
  •  标签:
  • mysql

我试图执行以下查询:

$query = "SELECT O. * AS NUM FROM (ab_order O)
    LEFT JOIN ab_user U ON (O.id_user=U.id)
    WHERE O.id IN ( SELECT OT.id_ab_order FROM ab_order_transaction OT
        LEFT JOIN ab_transaction T ON (OT.id_ab_transaction = T.id)
    LEFT JOIN ab_user U ON (T.id_user = U.id) 
    WHERE T.validated = 1 {$condTrans} ) {$condOrder}
    ORDER BY {$orderCol} LIMIT $from, $numRecords ";
$queryDB = $DB->queryExec($query);

在直播服务器上 :

  • it works with MySql version 3.3.10.
  • PHP version 5.2.17.

但我需要使用当地主机:

  • XAMPP for linux, v. 1.7.7
  • PHP 5.3.8
  • MySql version 5.5.16.

当地主机上写道:

MySQL error: 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  AS NUM
FROM (ab_order O)
LEFT JOIN ab_u  at line 1.

提升网络服务器Mysql数据库是否更容易?

问题回答

所有列的别名似乎不正确 : SELECT O. * AS NUM 。 我不知道为什么它会适用于以前的版本,但应该删除 as num ,或者明确标明每一列。

您可以在 SELECT 中为单列定义别名。 问题是

SELECT O. * AS NUM

替代此用途

SELECT O. * 

这是有用的文章",http://www.geeksengine.com/database/ basic-select/colun-alias.php" rel=“no follow”> SELECT 声明中的Using 列别





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签