MySQL上的错误与WHERE子句连接

时间:2014-02-28 08:00:21

标签: mysql sql phpmyadmin

我想要加入两个表,如果supplierprice.networkname=default那么我不想显示它。所以我的查询是:

SELECT 
    supplierprice.country, 
    supplierprice.networkname, 
    supplierprice.mcc, 
    supplierprice.mnc, 
    `301`.clientprice, 
    client_list.currency
FROM 
    supplierprice 
INNER JOIN 
    `301` 
ON 
   supplierprice.supp_price_id = `301`.net_id
INNER JOIN 
    client_list 
ON 
    `301`.clientid = client_list.clientid  
WHERE 
    supplierprice.networkname <>default 
AND ORDER BY 
    supplierprice.country ASC,supplierprice.networkname ASC 

我收到以下错误:

  

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近'和ORDER BY supplierprice.country ASC,supplierprice.networkname   ASC LIMIT 0,'第4行

任何人都可以帮助解决问题

1 个答案:

答案 0 :(得分:1)

并且不应介于Where和Order By之间

您也可以这样订购

ORDER BY supplierprice.country,supplierprice.networkname ASC

如果Default是列值,则将其作为'default'

传递

试试这个

SELECT supplierprice.country, supplierprice.networkname, supplierprice.mcc, supplierprice.mnc, `301`.clientprice, client_list.currency
FROM supplierprice 
INNER JOIN `301` ON supplierprice.supp_price_id = `301`.net_id
INNER JOIN client_list ON `301`.clientid = client_list.clientid  
where supplierprice.networkname <> 'default'
ORDER BY supplierprice.country,supplierprice.networkname ASC 
  

选择语法

SELECT
    [ALL | DISTINCT | DISTINCTROW ]
      [HIGH_PRIORITY]
      [STRAIGHT_JOIN]
      [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
      [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
    select_expr [, select_expr ...]
    [FROM table_references
    [WHERE where_condition]
    [GROUP BY {col_name | expr | position}
      [ASC | DESC], ... [WITH ROLLUP]]
    [HAVING where_condition]
    [ORDER BY {col_name | expr | position}
      [ASC | DESC], ...]
    [LIMIT {[offset,] row_count | row_count OFFSET offset}]
    [PROCEDURE procedure_name(argument_list)]
    [INTO OUTFILE 'file_name' export_options
      | INTO DUMPFILE 'file_name'
      | INTO var_name [, var_name]]
    [FOR UPDATE | LOCK IN SHARE MODE]]