Question

I have two tables I want to join and if supplierprice.networkname=default then i don't want to display that. so my query is:

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 

I am getting the following error:

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 'and ORDER BY supplierprice.country ASC,supplierprice.networkname ASC LIMIT 0, ' at line 4

can any one help how to fix

Was it helpful?

Solution

And should not come between Where and Order By

You can Order like this also

ORDER BY supplierprice.country,supplierprice.networkname ASC

and If Default is column value then pass it as 'default'

Try this

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 SYNTAX

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]]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top