Md. Mostafizur Rahman Md. Mostafizur Rahman - 7 months ago 11
SQL Question

how to use where and and order by together in sql?

select
Orders.OrderID,
Orders.OrderDate,
Customers.CustomerID,
Customers.City,
Customers.Country
from
Orders,
Customers
where
(Customers.City like '[abc]%') and
order by Customers.Country desc;


It shows the following error :


Syntax error (missing operator) in query expression '(Customers.City
like '[abc]%') and'


I am not so expert in sql.

so please help me .

Answer

You should remove and before order by

select  Orders.OrderID, Orders.OrderDate,  Customers.CustomerID, Customers.City,Customers.Country 
from Orders, Customers 
where (Customers.City like '[abc]%') 
/*and you should add a condition something like 
  Orders.CustomerID= Customers.CustomerID*/
order by Customers.Country desc;
Comments