Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 'where o.date_ordered='2011-01-10'' at line 2

this is the error i got and i am not getting sufficient output

What I have tried:

SQL
select o.order_id,p.product_id from orders o,products8 p,order_products8 t where o.order_id=t.order_id and p.product_id=t.product_id
where o.date_ordered='2011-01-10';
Posted
Updated 26-Feb-19 0:45am
v2
Comments
Herman<T>.Instance 26-Feb-19 6:07am    
did you try 2011/1/10 ?
Member 14163078 26-Feb-19 6:13am    
yes

Why do you have two WHERE clauses?
And you should probably look at a JOIN instead of trying to select from multiple tables. I can't write it for you - I have no idea of your tables and how they are interrelated, but:
C#
SELECT a.Name, b.Address FROM Users a
JOIN Addresses b ON a.ID = b.User_ID
WHERE a.JoinDate >= '2018-01-01'
 
Share this answer
 
v2
Comments
Maciej Los 26-Feb-19 6:28am    
You mean "WHERE" (not "WHILE") clauses...
OriginalGriff 26-Feb-19 6:37am    
Oh C**k.
Fixed :thumbsup:
Maciej Los 26-Feb-19 6:47am    
;)Have a nice day, OG (Paul)!
Assuming that order_products8 is a table with many to many relationships between orders and products8 tables,

- to get count of products
SQL
SELECT op.order_id, COUNT(op.product_id) CountOfProductsInOrder
FROM order_products8 AS op
GROUPBY op.order_id
WHERE op.date_ordered='2011-01-10';


- to get max number of products in order
SQL
SELECT dt.order_id, MAX(CountOfProductsInOrder) TheHigestNumberOfProductsInOrder
FROM (
-- use above query here
) AS dt
GROUPBY dt.order_id;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900