Reputation: 105
I'm running this query:
select sm.stockid as 'id',description as 'descripcion',price as 'precio'
from stockmaster as 'sm', prices as 'pc'
where
sm.stockid=pc.stockid and
sm.stockid='ESPOLVOREO' and
curdate() between pc.startdate and pc.enddate;
And I keep getting this error, I don't kwon why :/
#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 ''sm', prices as 'pc' where sm.stockid=pc.stockid and sm.stockid='ESPOLVOREO' a' at line 2
I'm running the query directly on the db. Thank you
Upvotes: 1
Views: 44
Reputation: 2734
First of all, as user3456640 states, don't write your aliases with quotes.
SELECT sm.stockid AS id, description AS descripcion, price AS precio
Secondly, Your missing some aliasses in the calls. Should look like this.
SELECT sm.stockid AS id,
sm.description AS descripcion,
pc.price AS precio
FROM stockmaster AS sm, prices AS pc
where
sm.stockid=pc.stockid AND
sm.stockid='ESPOLVOREO' AND
curdate() BETWEEN pc.startdate AND pc.enddate;
Upvotes: 0
Reputation: 1687
description as 'descripcion', price as 'precio'
change to
sm.description as 'descripcion', sm.price as 'precio'
regarding table you need (added table name before column name).
Upvotes: 0
Reputation: 111219
Don't put the table alias in quotes.
from stockmaster as sm, prices as pc
Upvotes: 2